StdLib.UniqueArray
Unique Array class For working with unique string array values. Creates an array with hash/dictionary indexing.
@usage local uniquearray = require('_krystdlib_/stdlib/utils/classes/unique_array') local myarray = uniquearray('first') my_array:add('second') if my_array['second'] then print('its truthy') end' @set all=true
Methods18
function UniqueArray.new(...: StdLib.UniqueArray | string | string[]) -> new StdLib.UniqueArray
Create a new unique array.
...StdLib.UniqueArray | string | string[]} strings to initialize the unique array with
function UniqueArray.add(other: StdLib.UniqueArray | string | string[]) -> self StdLib.UniqueArray
Add a string to the array if it doesn't exist in the array.
otherStdLib.UniqueArray | string | string[]}
function UniqueArray.remove(other: StdLib.UniqueArray | string | string[]) -> self StdLib.UniqueArray
Remove the strings from the array if they exist.
otherStdLib.UniqueArray | string | string[]}
function UniqueArray.toggle(other: StdLib.UniqueArray | string | string[]) -> self StdLib.UniqueArray
Toggles the passed name in the array by adding it if not present or removing it if it is.
function UniqueArray.diff(other: StdLib.UniqueArray | string | string[]) -> new StdLib.UniqueArray
Get all items that are NOT in both arrays.
otherStdLib.UniqueArray | string | string[]}
function UniqueArray.intersects(other: StdLib.UniqueArray | string | string[]) -> new StdLib.UniqueArray
Get all items that are in both arrays.
otherStdLib.UniqueArray | string | string[]}
function UniqueArray.sort(cmp: nil | function) -> self StdLib.UniqueArray
Sort the UniqueArray in place.
cmpnil | function[opt] Comparator @{sort} function to use
function UniqueArray.concat(other: StdLib.UniqueArray | string | string[]) -> new StdLib.UniqueArray
Create a new UniqueArray by concatenating together.
function UniqueArray.find(pattern: string) -> new StdLib.UniqueArray
Find all members in a unique array that match the pattern.
patternstringLua @{pattern}
newStdLib.UniqueArrayunique array containing all elements that match.
function UniqueArray.clear() -> self StdLib.UniqueArray
Clear the array returning an empty array object
function UniqueArray.all(other: StdLib.UniqueArray | string | string[]) -> every boolean
Does this array have all of the passed strings.
otherStdLib.UniqueArray | string | string[]}
everybooleanpassed string is in the array
function UniqueArray.has(other: StdLib.UniqueArray | string | string[]) -> every boolean
otherStdLib.UniqueArray | string | string[]}
everybooleanpassed string is in the array
function UniqueArray.any(other: StdLib.UniqueArray | string | string[]) -> any boolean
Does this array have any of the passed strings.
otherStdLib.UniqueArray | string | string[]}
anybooleanpassed string is in the array
function UniqueArray.none(other: StdLib.UniqueArray | string | string[]) -> no boolean
Does this array have none of the passed strings.
otherStdLib.UniqueArray | string | string[]}
nobooleanpassed strings are in the array
function UniqueArray.same(other: StdLib.UniqueArray | string | string[]) -> boolean
Do both arrays contain the same items
otherStdLib.UniqueArray | string | string[]}
- boolean
function UniqueArray.disjointed(other: StdLib.UniqueArray | string | string[]) -> boolean
Do the unique arrays have no items in common
otherStdLib.UniqueArray | string | string[]}
- boolean
function UniqueArray.tostring() -> string
Convert the array to a string.
function UniqueArray.make_dictionary(func: nil | function, ...: any[opt]) -> { [any]: any }
Return a dictionary mapping of the array. can be passed a function to set the value of the field.
funcnil | function[opt] value, index are passed as the first two paramaters
...any[opt]additional values to pass to the function
- { [any]: any }
Fields1
UniqueArray.__class: string = "UniqueArray"