Documentation ¶
Index ¶
- type Item
- type RankedSet
- func (s *RankedSet) Delete(item Item) Item
- func (s *RankedSet) Get(item Item) Item
- func (s *RankedSet) Has(item Item) bool
- func (s *RankedSet) Insert(item Item) Item
- func (s *RankedSet) Len() int
- func (s *RankedSet) LessThan(rank int64, delete bool) []Item
- func (s *RankedSet) List(delete bool) []Item
- func (s *RankedSet) Max() Item
- func (s *RankedSet) Min() Item
- type StringItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item interface { // Key returns the unique identifier for this item. Key() string // Rank is used to sort items. // Items with the same rank are sorted lexicographically based on Key. Rank() int64 }
Item represents a single object in a RankedSet.
type RankedSet ¶
type RankedSet struct {
// contains filtered or unexported fields
}
RankedSet stores Items based on Key (uniqueness) and Rank (sorting).
func (*RankedSet) Delete ¶
Delete removes the item from the set based on Key (Rank is ignored). The removed item is returned if it existed in the set.
func (*RankedSet) Insert ¶
Insert adds the item into the set. If an item with the same Key existed in the set, it is deleted and returned.
func (*RankedSet) LessThan ¶
LessThan returns all items less than the given rank in ranked order. If delete is set to true, the returned items are removed from the set.
type StringItem ¶
type StringItem string
StringItem implements Item using a string. It has two main uses: 1. If all items in a RankedSet are StringItems, the set becomes a store of unique strings sorted lexicographically. 2. It serves as a Key item that can be passed into methods that ignore Rank such as RankedSet.Delete.
func (StringItem) Key ¶
func (s StringItem) Key() string
func (StringItem) Rank ¶
func (s StringItem) Rank() int64