LogoAntiRaid

@antiraid-ext/set

API reference for @antiraid-ext/set

@antiraid-ext/set

Types

Set

Sets

Sets can add/get unique elements.

Usage notes

  1. 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
}
PropTypeDescription
add
(element: K) -> ()
Adds an element to the set
insert
(elements: {K}) -> ()
Inserts a set of elements into the set
remove
(element: K) -> ()
Removes an element from the set
delete
(elements: {K}) -> ()
Deletes a set of elements from the set
exists
(element: K) -> boolean
Returns if an element exists in the priority set or not
clear
() -> ()
Clears the set
copy
() -> Set&lt;K&gt;
Copy of the set**Time complexity: O(n)** where `n` is the number of elements in the set.
__iter
(self) -> () -> K?
-
__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

Set<K>

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

Set<K>

Last updated on