@antiraid-ext/set
API reference for @antiraid-ext/set
@antiraid-ext/set
Types
Set
Sets
Sets can add/get unique elements.
Usage notes
- The elements stored must be hashable (e.g. strings, numbers, etc.).
Raw Type
--- Sets
---
--- Sets can add/get unique elements.
---
--- **Usage notes**
---
--- 1. The elements stored must be hashable (e.g. strings, numbers, etc.).
type Set<K> = {
--- Adds an element to the set
add: (element: K) -> (),
--- Inserts a set of elements into the set
insert: (elements: {K}) -> (),
--- Removes an element from the set
remove: (element: K) -> (),
--- Deletes a set of elements from the set
delete: (elements: {K}) -> (),
--- Returns if an element exists in the priority set or not
exists: (element: K) -> boolean,
--- Clears the set
clear: () -> (),
--- Copy of the set
---
--- **Time complexity: O(n)** where \`n\` is the number of elements in the set.
copy: () -> Set<K>,
-- Metatable
__iter: (self: Set<K>) -> () -> K?,
__len: (self: Set<K>) -> number
}
Prop | Type | Description |
---|---|---|
add | Adds an element to the set | |
insert | Inserts a set of elements into the set | |
remove | Removes an element from the set | |
delete | Deletes a set of elements from the set | |
exists | Returns if an element exists in the priority set or not | |
clear | () -> () | Clears the set |
copy | Copy of the set**Time complexity: O(n)** where `n` is the number of elements in the set. | |
__iter | - | |
__len | (self) -> number | - |
Functions
Set
Function Signature
function Set<K>() -> Set<K> end
Generics
K
This generic is unconstrained and can be any type
Returns
ret1
fromtable
Creates a set from a table of elements
Time complexity: O(n) where `n` is the number of elements in the table.
Function Signature
--- Creates a set from a table of elements
---
--- **Time complexity: O(n)** where \`n\` is the number of elements in the table.
function fromtable<K>(table: {K}) -> Set<K> end
Generics
K
This generic is unconstrained and can be any type
Arguments
table
{K}
Returns
ret1
Last updated on