Arrays & Maps
ArrayUtil & MapUtil
Last updated
ArrayUtil & MapUtil
Last updated
An ArrayUtil is a dynamic array-like data structure that can store elements of any type. Conceptually, it behaves like an array but with additional functionalities and flexibility.
ArrayUtils.empty(<T>) -> Array<T>
: Returns new empty array of type T
.
add(value: T)
: Adds a value to the array.
set(index: Integer, value: T)
: Sets the value of the element at the given index
.
remove(index: Integer)
: Removes the value in the array at index.
size() -> Integer
: returns the size of the array.
clear()
: Clears the array removing all it's values.
A map represented as HashMap<Object, Object>
, is a collection that associates unique keys with corresponding values, facilitating efficient retrieval and modification of data based on key references.
A
{
followed by zero or more sets ofkey : value
pairs separated by,
and ending with}
, e.g.{ "one" : 1, "two" : 2, "three" : 3, "more": "many more" }
This syntax creates a
HashMap<Object,Object>
.Empty map literal can be specified as
{:}
create(); Map
Creates an empty map and returns it.
add(Map<String, Object> map, String key, Object value): void
adds a key-value pair to map. Returns nothing
size(); Integer
Returns number of key-value pairs in map.
isEmpty: Boolean
Returns true of map is empty, otherwise returns false.
cotainsKey(Object key): Boolean
Returns true if map contains specified key, otherwise returns false.
containsValue(Object value): Boolean
Returns true if map contains specified value, otherwise returns false.
remove(String key): Object
Removes key from Map and returns the remove value object.
keySet(); and values();
Return the keys and values of the map, respectively.
Or you can define map Manually:
HashMaps are especially useful for defining a row in