Documentation ¶
Overview ¶
Package ds implements useful data structures for sprig.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommunityList ¶
type CommunityList struct {
// contains filtered or unexported fields
}
CommunityList holds a sortable list of communities that can update itself automatically by subscribing to a store.ExtendedStore
func NewCommunityList ¶
func NewCommunityList(s store.ExtendedStore) (*CommunityList, error)
NewCommunityList creates a CommunityList and subscribes it to the provided ExtendedStore. It will prepopulate the list with the contents of the store as well.
func (*CommunityList) IndexForID ¶
func (c *CommunityList) IndexForID(id *fields.QualifiedHash) int
IndexForID returns the position of the node with the given `id` inside of the CommunityList, or -1 if it is not present.
func (*CommunityList) WithCommunities ¶
func (c *CommunityList) WithCommunities(closure func(communities []*forest.Community))
WithCommunities executes an arbitrary closure with access to the communities stored inside of the CommunitList. The closure must not modify the slice that it is given.
type NodeList ¶
NodeList implements a generic data structure for storing ordered lists of forest nodes.
func NewNodeList ¶
func NewNodeList(filter NodeFilter, sort NodeSorter, initialize func() []forest.Node, s store.ExtendedStore) *NodeList
NewNodeList creates a nodelist subscribed to the provided store and initialized with the return value of initialize(). The nodes will be sorted using the provided sort function (via sort.Slice) and nodes will only be inserted into the list if the filter() function returns non-nil for them. The filter function may transform the data before inserting it.
func (*NodeList) IndexForID ¶
func (n *NodeList) IndexForID(id *fields.QualifiedHash) int
IndexForID returns the position of the node with the given `id` inside of the CommunityList, or -1 if it is not present.
type NodeSorter ¶
type ReplyData ¶ added in v0.0.9
ReplyData holds the contents of a single reply and the major nodes that it references.
type ReplyList ¶
type ReplyList struct {
// contains filtered or unexported fields
}
ReplyList holds a sortable list of replies that can update itself automatically by subscribing to a store.ExtendedStore
func NewReplyList ¶
func NewReplyList(s store.ExtendedStore) (*ReplyList, error)
NewReplyList creates a ReplyList and subscribes it to the provided ExtendedStore. It will prepopulate the list with the contents of the store as well.
func (*ReplyList) IndexForID ¶
func (c *ReplyList) IndexForID(id *fields.QualifiedHash) int
IndexForID returns the position of the node with the given `id` inside of the ReplyList, or -1 if it is not present.
func (*ReplyList) WithReplies ¶
WithReplies executes an arbitrary closure with access to the replies stored inside of the ReplyList. The closure must not modify the slice that it is given.