Documentation
¶
Index ¶
- type BiIndex
- func (s *BiIndex) Assign(name string) (int, bool)
- func (s *BiIndex) Clear()
- func (s *BiIndex) Clone() *BiIndex
- func (s *BiIndex) DeleteAndShift(id int) (string, map[int]int, bool)
- func (s *BiIndex) DeleteByID(id int) (string, bool)
- func (s *BiIndex) DeleteByName(name string) bool
- func (s *BiIndex) Get(id int) (string, bool)
- func (s *BiIndex) Has(name string) bool
- func (s *BiIndex) IDs() []int
- func (s *BiIndex) Index(name string) (int, bool)
- func (s *BiIndex) Len() int
- func (s *BiIndex) Set(id int, name string) (string, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BiIndex ¶
type BiIndex struct {
// contains filtered or unexported fields
}
BiIndex maps between integer ids and string names with stable ids. Deleted ids are pushed onto a free list for reuse.
func NewBiIndex ¶
NewBiIndex create a new BiIndex with optional capacity hint.
func (*BiIndex) Assign ¶
Assign assigns a new id for name if it doesn't exist, reusing freed ids if any. Returns (id, true) if newly assigned, or (existingID, false) if name existed.
func (*BiIndex) Clear ¶
func (s *BiIndex) Clear()
Clear removes all mappings and resets free list and counters.
func (*BiIndex) DeleteAndShift ¶
DeleteAndShift deletes the mapping at id and shifts all mappings with ids greater than id down by 1. It returns the deleted name, a mapping of oldID->newID for all shifted ids, and true on success. This operation is O(n) and will change many ids; mapping helps callers update references.
func (*BiIndex) DeleteByID ¶
DeleteByID removes the mapping at id and returns the deleted name. The id is pushed to free list for reuse.
func (*BiIndex) DeleteByName ¶
DeleteByName removes the mapping for name.