Skip to content

Set

Parameters

[DType = Dynamic, Hasher = MurMur3Hasher] 

Implements an ordered Hashtable using the provided Hasher. The order of insertion of items is preserved and items can be iterated bidirectionally from the beginning to the end and vice versa.

graph BT
N1["Set[DType,Hasher]"] -->|inherits| N2["ReverseIterable[DType]"];
N1["Set[DType,Hasher]"] -->|inherits| N3["Unpackable[DType]"];

Characteristics

Quality Value
Inherits ReverseIterable[DType], Unpackable[DType]
Extends N/A
Decorators #sealed;
Is enum false
Is sealed true
Is extern false

Type Aliases

ListData

ListData = Pair[Hasher.HashValueType, DType]

Methods

construct

construct (s Self) -> Self

init

init (s Self) -> Nil

get_iterator

get_iterator (s Self) -> DictIterator[Self]

get_reverse_iterator

get_reverse_iterator (s Self) -> DictIterator[Self]

len

#strict
len (s Self) -> Len
number of items in the set


copy

copy (s Self) -> strictly SelfType
create a new set with the same items as this set


add

add (s Self, item @DType) -> Nil
adds an item to the set. If the item already exists will replace the old items with the new one


remove

remove (s Self, item @DType) -> Nil
removes an item from the set. If the item does not exist the function quietly returns


first

first (s Self) -> DType?
return the first item in the set if applicable otherwise returns Nil


last

last (s Self) -> DType?
return the last item in the set if applicable otherwise returns Nil


pop

pop (s Self) -> DType?
removes and returns the last item in the set if applicable otherwise returns Nil


str

str (s Self, delimiter: String = `, `, quote_begin: String = ```, quote_end: String = ```, enclose_begin: String = `[`, enclose_end: String = `]`) -> String

__erase

__erase (s Self, index Len, list_ptr Pointer) -> Nil

__calculate_index

#Gambol.function.alwaysinline
__calculate_index (s Self, hash_value Hasher.HashValueType) -> Len

__grow_if_necessary

__grow_if_necessary (s Self) -> Nil

Binary Operators

is in

is in (s Self, item DType) -> Bool
true if item is in the set. false otherwise


==

== (s Self, o Self) -> Bool
two sets are equal if they have exactly the same items. Order of insertion is not considered when checking equality


<=

<= (s Self, o Self) -> Bool
true if this set is a subset of o


<

< (s Self, o Self) -> Bool
true if this set is a proper subset of o


>=

>= (s Self, o Self) -> Bool
true if o is a subset of this set


>

> (s Self, o Self) -> Bool
true if o is a proper subset of this set


|

| (s Self, o Self) -> strictly SelfType
returns a union of this set and o


|=

|= (s Self, o Self) -> Self
will add all elements of o to this set


&

& (s Self, o Self) -> strictly SelfType
returns a new set that is the intersection of this set and o


&=

&= (s Self, o Self) -> Self
will remove all elements in this set that are not in o


-

- (s Self, o Self) -> SelfType
will return a new set that is the same as this set with all elements that also exist in o removed


-=

-= (s Self, o Self) -> Self
will remove all elements in o from this set


^

^ (s Self, o Self) -> SelfType
will return a new set that is the symmetric difference of this set and o


^=

^= (s Self, o Self) -> Self
will remove items that exit in both sets from this set and add items in o that don't exist in this set to this set simultaneously


Properties

kInitSize

const global kInitSize Len = 64

kGrowthFactor

const global kGrowthFactor Len = 3

__table

__table List[Pointer](kInitSize)

__len

__len Len

__load

__load Len

__first_ptr

__first_ptr Pointer

__last_ptr

__last_ptr Pointer