github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/collection/iface.go (about) 1 package collection 2 3 import ( 4 breakLoop "github.com/m4gshm/gollections/break/loop" 5 "github.com/m4gshm/gollections/c" 6 kv "github.com/m4gshm/gollections/kv/collection" 7 "github.com/m4gshm/gollections/loop" 8 ) 9 10 // Iterable is a loop supplier interface 11 type Iterable[T any] c.Iterable[T, loop.Loop[T]] 12 13 // Collection is the base interface for the Vector and the Set impelementations 14 type Collection[T any] interface { 15 Iterable[T] 16 c.Collection[T] 17 c.Filterable[T, loop.Loop[T], breakLoop.Loop[T]] 18 c.Convertable[T, loop.Loop[T], breakLoop.Loop[T]] 19 20 Len() int 21 IsEmpty() bool 22 23 HasAny(func(T) bool) bool 24 } 25 26 // Vector - collection interface that provides elements order and access by index to the elements. 27 type Vector[T any] interface { 28 Collection[T] 29 30 c.Track[int, T] 31 c.TrackEach[int, T] 32 33 c.Access[int, T] 34 35 c.KVAll[int, T] 36 } 37 38 // Set - collection interface that ensures the uniqueness of elements (does not insert duplicate values). 39 type Set[T comparable] interface { 40 Collection[T] 41 c.Checkable[T] 42 43 c.All[T] 44 } 45 46 // Map - collection interface that stores key/value pairs and provide access to an element by its key 47 type Map[K comparable, V any] interface { 48 kv.Collection[K, V, map[K]V] 49 kv.Filterable[K, V] 50 kv.Convertable[K, V] 51 c.Checkable[K] 52 c.Access[K, V] 53 c.KVAll[K, V] 54 55 Len() int 56 IsEmpty() bool 57 58 HasAny(func(K, V) bool) bool 59 60 }