github.com/m4gshm/gollections@v0.0.10/collection/iface.go (about)

     1  package collection
     2  
     3  import (
     4  	breakKvstream "github.com/m4gshm/gollections/break/kv/stream"
     5  	breakStream "github.com/m4gshm/gollections/break/stream"
     6  	"github.com/m4gshm/gollections/c"
     7  	"github.com/m4gshm/gollections/kv"
     8  	kvstream "github.com/m4gshm/gollections/kv/stream"
     9  	"github.com/m4gshm/gollections/stream"
    10  )
    11  
    12  // Collection is the base interface for the Vector and the Set impelementations
    13  type Collection[T any] interface {
    14  	c.Collection[T]
    15  	c.Filterable[T, stream.Iter[T], breakStream.Iter[T]]
    16  	c.Convertable[T, stream.Iter[T], breakStream.Iter[T]]
    17  
    18  	Len() int
    19  	IsEmpty() bool
    20  
    21  	HasAny(func(T) bool) bool
    22  }
    23  
    24  // Vector - collection interface that provides elements order and access by index to the elements.
    25  type Vector[T any] interface {
    26  	Collection[T]
    27  
    28  	c.TrackLoop[int, T]
    29  	c.TrackEachLoop[int, T]
    30  
    31  	c.Access[int, T]
    32  }
    33  
    34  // Set - collection interface that ensures the uniqueness of elements (does not insert duplicate values).
    35  type Set[T comparable] interface {
    36  	Collection[T]
    37  	c.Checkable[T]
    38  }
    39  
    40  // Map - collection interface that stores key/value pairs and provide access to an element by its key
    41  type Map[K comparable, V any] interface {
    42  	kv.Collection[K, V, map[K]V]
    43  	kv.Filterable[K, V, kvstream.Iter[K, V, map[K]V], breakKvstream.Iter[K, V, map[K]V]]
    44  	kv.Convertable[K, V, kvstream.Iter[K, V, map[K]V], breakKvstream.Iter[K, V, map[K]V]]
    45  	c.Checkable[K]
    46  	c.Access[K, V]
    47  
    48  	Len() int
    49  	IsEmpty() bool
    50  
    51  	HasAny(func(K, V) bool) bool
    52  }