datastructure

package
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSuchElement   = errors.New("element does not exist")
	ErrInvalidArgument = errors.New("invalid argument")
)
View Source
var DEFAULT_OPTIONS = &LRUCacheOptions{
	EvictionCallback:  nil,
	EvictionBatchSize: 1,
	IdleTimeout:       30 * time.Second,
}

Functions

This section is empty.

Types

type DoublyLinkedList

type DoublyLinkedList struct {
	// contains filtered or unexported fields
}

func (*DoublyLinkedList) Add

func (list *DoublyLinkedList) Add(value interface{}) *DoublyLinkedListEntry

Appends the specified value to the end of this list.

func (*DoublyLinkedList) AddEntry

func (list *DoublyLinkedList) AddEntry(entry *DoublyLinkedListEntry)

Appends the specified element to the end of this list.

func (*DoublyLinkedList) AddFirst

func (list *DoublyLinkedList) AddFirst(value interface{}) *DoublyLinkedListEntry

func (*DoublyLinkedList) AddFirstEntry

func (list *DoublyLinkedList) AddFirstEntry(entry *DoublyLinkedListEntry)

func (*DoublyLinkedList) AddLast

func (list *DoublyLinkedList) AddLast(value interface{}) *DoublyLinkedListEntry

func (*DoublyLinkedList) AddLastEntry

func (list *DoublyLinkedList) AddLastEntry(entry *DoublyLinkedListEntry)

func (*DoublyLinkedList) Clear

func (list *DoublyLinkedList) Clear()

func (*DoublyLinkedList) GetFirst

func (list *DoublyLinkedList) GetFirst() (interface{}, error)

func (*DoublyLinkedList) GetFirstEntry

func (list *DoublyLinkedList) GetFirstEntry() (*DoublyLinkedListEntry, error)

func (*DoublyLinkedList) GetLast

func (list *DoublyLinkedList) GetLast() (interface{}, error)

func (*DoublyLinkedList) GetLastEntry

func (list *DoublyLinkedList) GetLastEntry() (*DoublyLinkedListEntry, error)

func (*DoublyLinkedList) GetSize

func (list *DoublyLinkedList) GetSize() int

func (*DoublyLinkedList) Remove

func (list *DoublyLinkedList) Remove(value interface{}) error

func (*DoublyLinkedList) RemoveEntry

func (list *DoublyLinkedList) RemoveEntry(entry *DoublyLinkedListEntry) error

func (*DoublyLinkedList) RemoveFirst

func (list *DoublyLinkedList) RemoveFirst() (interface{}, error)

func (*DoublyLinkedList) RemoveFirstEntry

func (list *DoublyLinkedList) RemoveFirstEntry() (*DoublyLinkedListEntry, error)

func (*DoublyLinkedList) RemoveLast

func (list *DoublyLinkedList) RemoveLast() (interface{}, error)

func (*DoublyLinkedList) RemoveLastEntry

func (list *DoublyLinkedList) RemoveLastEntry() (*DoublyLinkedListEntry, error)

type DoublyLinkedListEntry

type DoublyLinkedListEntry struct {
	// contains filtered or unexported fields
}

func (*DoublyLinkedListEntry) GetNext

func (entry *DoublyLinkedListEntry) GetNext() *DoublyLinkedListEntry

func (*DoublyLinkedListEntry) GetPrev

func (entry *DoublyLinkedListEntry) GetPrev() *DoublyLinkedListEntry

func (*DoublyLinkedListEntry) GetValue

func (entry *DoublyLinkedListEntry) GetValue() interface{}

func (*DoublyLinkedListEntry) SetNext

func (entry *DoublyLinkedListEntry) SetNext(next *DoublyLinkedListEntry)

func (*DoublyLinkedListEntry) SetPrev

func (entry *DoublyLinkedListEntry) SetPrev(prev *DoublyLinkedListEntry)

func (*DoublyLinkedListEntry) SetValue

func (entry *DoublyLinkedListEntry) SetValue(value interface{})

type KRWMutex

type KRWMutex struct {
	// contains filtered or unexported fields
}

func NewKRWMutex

func NewKRWMutex() *KRWMutex

func (*KRWMutex) Free

func (kwrMutex *KRWMutex) Free(key interface{})

func (*KRWMutex) Register

func (krwMutex *KRWMutex) Register(key interface{}) (result *syncutils.RWMutex)

type LRUCache

type LRUCache struct {
	// contains filtered or unexported fields
}

func NewLRUCache

func NewLRUCache(capacity int, options ...*LRUCacheOptions) *LRUCache

func (*LRUCache) ComputeIfAbsent

func (cache *LRUCache) ComputeIfAbsent(key interface{}, callback func() interface{}) (result interface{})

func (*LRUCache) ComputeIfPresent

func (cache *LRUCache) ComputeIfPresent(key interface{}, callback func(value interface{}) interface{}) (result interface{})

Calls the callback if an entry with the given key exists. The result of the callback is written back into the cache. If the callback returns nil the entry is removed from the cache. Returns the updated entry.

func (*LRUCache) Contains

func (cache *LRUCache) Contains(key interface{}) (result bool)

func (*LRUCache) Delete

func (cache *LRUCache) Delete(key interface{}) bool

func (*LRUCache) DeleteAll

func (cache *LRUCache) DeleteAll()

func (*LRUCache) DeleteWithoutEviction

func (cache *LRUCache) DeleteWithoutEviction(key interface{}) (existed bool, keyToEvict interface{}, valueToEvict interface{})

func (*LRUCache) Get

func (cache *LRUCache) Get(key interface{}) (result interface{})

func (*LRUCache) GetCapacity

func (cache *LRUCache) GetCapacity() int

func (*LRUCache) GetSize

func (cache *LRUCache) GetSize() int

func (*LRUCache) Set

func (cache *LRUCache) Set(key interface{}, value interface{})

type LRUCacheOptions

type LRUCacheOptions struct {
	EvictionCallback  func(keyOrBatchedKeys interface{}, valueOrBatchedValues interface{})
	EvictionBatchSize uint64
	IdleTimeout       time.Duration
}

type RandomMap

type RandomMap struct {
	// contains filtered or unexported fields
}

func NewRandomMap

func NewRandomMap() *RandomMap

func (*RandomMap) Delete

func (rmap *RandomMap) Delete(key interface{}) (result interface{}, exists bool)

func (*RandomMap) Get

func (rmap *RandomMap) Get(key interface{}) (result interface{}, exists bool)

func (*RandomMap) RandomEntry

func (rmap *RandomMap) RandomEntry() (result interface{})

func (*RandomMap) Set

func (rmap *RandomMap) Set(key interface{}, value interface{})

func (*RandomMap) Size

func (rmap *RandomMap) Size() (result int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL