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

     1  package mapset
     2  
     3  import (
     4  	"github.com/djordje200179/extendedlibrary/datastructures/maps"
     5  )
     6  
     7  // Iterator is an iterator over a set.
     8  type Iterator[T any] struct {
     9  	mapIt maps.Iterator[T, empty]
    10  }
    11  
    12  // Valid returns true if the iterator is pointing to a valid element.
    13  func (it Iterator[T]) Valid() bool {
    14  	return it.mapIt.Valid()
    15  }
    16  
    17  // Move moves the iterator to the next element.
    18  func (it Iterator[T]) Move() {
    19  	it.mapIt.Move()
    20  }
    21  
    22  // Get returns the current element.
    23  func (it Iterator[T]) Get() T {
    24  	return it.mapIt.Key()
    25  }
    26  
    27  // Remove removes the current element from the set.
    28  func (it Iterator[T]) Remove() {
    29  	it.mapIt.Remove()
    30  }