Unique Array class For working with unique string array values.
Creates an array with hash/dictionary indexing. Adding or removeing values without using the provided methods can break the functionality of this class. Additional methods exported by requering unique_array are .set and .make_dictionary
local Unique_Array = require('__stdlib__/stdlib/utils/classes/unique_array')
local my_array = Unique_Array('first')
my_array:add('second')
if my_array['second'] then
print('its truthy')
end'
unique_array:new(...) | Create a new unique array. |
unique_array:add(other) | Add a string to the array if it doesn’t exist in the array. |
unique_array:remove(other) | Remove the strings from the array if they exist. |
unique_array:toggle(other) | Toggles the passed name in the array by adding it if not present or removing it if it is. |
unique_array:diff(other) | Get all items that are NOT in both arrays. |
unique_array:intersects(other) | Get all items that are in both arrays. |
unique_array:sort([cmp]) | Sort the unique_array in place. |
unique_array:concat(other) | Create a new unique_array by concatenating together. |
unique_array:find(pattern) | Find all members in a unique array that match the pattern. |
unique_array:clear() | Clear the array returning an empty array object |
unique_array:all(other) | Does this array have all of the passed strings. |
unique_array:any(other) | Does this array have any of the passed strings. |
unique_array:none(other) | Does this array have none of the passed strings. |
unique_array:same(other) | Do both arrays contain the same items |
unique_array:disjointed(other) | Do the unique arrays have no items in common |
unique_array:tostring() | Convert the array to a string. |
unique_array:make_dictionary([func][, ...]) | Return a dictionary mapping of the array. |
unique_array.exports | These functions are available when requiring this class. |
Create a new unique array.
Parameters:
Add a string to the array if it doesn’t exist in the array.
Parameters:
Remove the strings from the array if they exist.
Parameters:
Toggles the passed name in the array by adding it if not present or removing it if it is.
Parameters:
Get all items that are NOT in both arrays.
Parameters:
Get all items that are in both arrays.
Parameters:
Sort the unique_array in place.
Parameters: Returns:
Create a new unique_array by concatenating together.
Parameters:
Find all members in a unique array that match the pattern.
Parameters: Returns:
Clear the array returning an empty array object
Returns:
Does this array have all of the passed strings.
Parameters:
Does this array have any of the passed strings.
Parameters:
Does this array have none of the passed strings.
Parameters:
Do both arrays contain the same items
Parameters:
Do the unique arrays have no items in common
Parameters:
Convert the array to a string.
Returns:
Return a dictionary mapping of the array.
can be passed a function to set the value of the field.
Parameters:These functions are available when requiring this class.
Fields: