github.com/djordje200179/extendedlibrary/datastructures@v1.7.1-0.20240227175559-d09520a92dd4/sets/interfaces.go (about)

     1  package sets
     2  
     3  import (
     4  	"github.com/djordje200179/extendedlibrary/datastructures/iter"
     5  	"github.com/djordje200179/extendedlibrary/misc"
     6  )
     7  
     8  // Iterator is an iterator over a set.
     9  type Iterator[T any] interface {
    10  	iter.Iterator[T]
    11  
    12  	// Remove removes the current element
    13  	Remove()
    14  }
    15  
    16  // Set is an interface that represents a set of elements
    17  type Set[T any] interface {
    18  	// Size returns the size of the set
    19  	Size() int
    20  
    21  	// Add adds the given value to the set
    22  	Add(value T)
    23  	// Remove removes the given value from the set
    24  	Remove(value T)
    25  	// Contains returns true if the set contains the given value
    26  	Contains(value T) bool
    27  
    28  	// Clear clears the set
    29  	Clear()
    30  	misc.Cloner[Set[T]]
    31  
    32  	iter.Iterable[T]
    33  	// SetIterator returns an iterator over the set
    34  	SetIterator() Iterator[T]
    35  	// Stream streams elements of the set
    36  	Stream(yield func(T) bool)
    37  }