Interfaces
interface Deque<T>
public interface Deque<T> <: Collection<T> {
prop first: ?T
prop last: ?T
func addFirst(element: T): Unit
func addLast(element: T): Unit
func removeFirst(): ?T
func removeLast(): ?T
}
Description: Specifies a double-ended queue (Deque) which is a data structure with queue and stack features, allowing elements to be added and deleted at both ends. The Deque interface provides the following functions:
- Addition: The first or last element of a double-ended queue can be added. The addFirst method is used to add the first element of a double-ended queue, and the addLast method is used to add the last element of a double-ended queue.
- Access: The first or last element of a double-ended queue can be accessed without being deleted. The first method is used to access the first element, and the last method is used to access the last element.
- Deletion: The first or last element of a double-ended queue can be deleted. The removeFirst method is used to delete the first element and return its value, and the removeLast method is used to delete the last element and return its value.
- Operations supported for other collection types, such as operations involving the number of elements, null check, and iterator.
Parent types:
- Collection<T>
prop first
prop first: ?T
Description: Accesses the first element of a double-ended queue. This operation does not delete the first element.
Returns:
- Option<T>: value of the first element encapsulated with Option. If the double-ended queue is empty, None is returned.
prop last
prop last: ?T
Description: Accesses the last element of a double-ended queue. This operation does not delete the last element.
Returns:
- Option<T>: value of the last element encapsulated with Option. If the double-ended queue is empty, None is returned.
func addFirst(T)
func addFirst(element: T): Unit
Description: Adds a specified first element to a double-ended queue.
Parameters:
- element: T: element to be added to a double-ended queue
func addLast(T)
func addLast(element: T): Unit
Description: Adds a specified last element to a double-ended queue.
Parameters:
- element: T: element to be added to a double-ended queue
func removeFirst()
func removeFirst(): ?T
Description: Deletes the first element of a double-ended queue and returns the value of the element.
Returns:
- ?T: value of the deleted element encapsulated with Option. If the double-ended queue is empty, None is returned.
func removeLast()
func removeLast(): ?T
Description: Deletes the last element of a double-ended queue and returns the value of the element.
Returns:
- ?T: value of the deleted element encapsulated with Option. If the double-ended queue is empty, None is returned.
interface EquatableCollection<T>
public interface EquatableCollection<T> <: Collection<T> {
func contains(element: T): Bool
func contains(all!: Collection<T>): Bool
}
Description: Defines the types of collections that support the comparison operation.
Parent types:
- Collection<T>
func contains(T)
func contains(element: T): Bool
Description: Checks whether keys contain a specified element.
Parameters:
- element: T: specified element to be checked whether contained in keys
Returns:
- Bool: If the specified element is contained, true is returned. Otherwise, false is returned.
func contains(Collection<T>)
func contains(all!: Collection<T>): Bool
Description: Checks whether keys contain all elements in a specified collection.
Parameters:
- all!: Collection<T>: collection to be checked
Returns:
- Bool: If all elements are contained, true is returned. Otherwise, false is returned.
interface List<T>
public interface List<T> <: ReadOnlyList<T> {
func add(element: T): Unit
func add(all!: Collection<T>): Unit
func add(element: T, at!: Int64): Unit
func add(all!: Collection<T>, at!: Int64): Unit
func remove(at!: Int64): T
func remove(range: Range<Int64>): Unit
func removeIf(predicate: (T) -> Bool): Unit
func clear(): Unit
operator func [](index: Int64, value!: T): Unit
}
Description: Defines the list types that only support index-friendly operations.
Parent types:
- ReadOnlyList<T>
func add(T)
func add(element: T): Unit
Description: Appends a specified element to the end of a list.
Parameters:
- element: T: added element of the
Ttype
func add(Collection<T>)
func add(all!: Collection<T>): Unit
Description: Appends all elements in a specified collection to the end of a list.
Parameters:
- all!: Collection<T>: collection of elements to be added
func add(T, Int64)
func add(element: T, at!: Int64): Unit
Description: Adds a specified element to a specified position in a list.
Parameters:
- element: T: element of the
Ttype to be added - at!: Int64: target index of the element to be added
func add(Collection<T>, Int64)
func add(all!: Collection<T>, at!: Int64): Unit
Description: Adds all elements in a specified collection to a list starting from a specified position.
Parameters:
- all!: Collection<T>: collection of elements of the
Ttype to be added - at!: Int64: target index of the collection to be added
func clear()
func clear(): Unit
Description: Deletes all elements from a list.
func remove(Int64)
func remove(at!: Int64): T
Description: Deletes an element from a specified position in a list.
Parameters:
- at!: Int64: index of the element to be deleted
Returns:
- T: deleted element
func remove(Range<Int64>)
func remove(range: Range<Int64>): Unit
Description: Deletes all elements contained in Range of a list.
Parameters:
func removeIf((T) -> Bool)
func removeIf(predicate: (T) -> Bool): Unit
Description: Deletes all elements that meet a given lambda expression or function in a list.
Parameters:
- predicate: (T) ->Bool: condition used for determining deletion
operator func [](Int64, T)
operator func [](index: Int64, value!: T): Unit
Description: Overloads the operator using get, that is, replaces an element at a specified position in a list with a specified element using an index operator.
Parameters:
- index: Int64: index to be set
- value!: T: value of the
Ttype to be set
interface Map<K, V>
public interface Map<K, V> <: ReadOnlyMap<K, V> {
func add(key: K, value: V): ?V
func add(all!: Collection<(K, V)>): Unit
func addIfAbsent(key: K, value: V): ?V
func clear(): Unit
func entryView(k: K): MapEntryView<K, V>
func remove(key: K): Option<V>
func remove(all!: Collection<K>): Unit
func removeIf(predicate: (K, V) -> Bool): Unit
func replace(key: K, value: V): ?V
operator func [](key: K, value!: V): Unit
}
Description: Provides a method of mapping keys to values. The method supports using keys to find values, so it can be used to store and operate key-value pairs.
A map instance cannot contain duplicate keys. Each key can be mapped to only one value.
Parent types:
- ReadOnlyMap<K, V>
func add(K, V)
func add(key: K, value: V): ?V
Description: Puts a passed key-value pair into a map instance. For an existing key in a map instance that is the same as the new key to be passed, the value mapped to the key is replaced with the new value.
Parameters:
- key: K: key to be put
- value: V: value to be allocated
Returns:
- ?V: If the key exists before the value is assigned, the old value is returned. Otherwise, None is returned.
func add(Collection<(K, V)>)
func add(all!: Collection<(K, V)>): Unit
Description: Puts new key-value pairs into a map instance. For an existing key in a map instance that is the same as the new key to be passed, the value mapped to the key is replaced with the new value.
Parameters:
- all!: Collection<(K, V)>: collection of key-value pairs to be put into the map instance
func addIfAbsent(K, V)
func addIfAbsent(key: K, value: V): ?V
Description: If a key is not in the current map instance, adds the specified key-value pair. Otherwise, no modification is required.
Parameters:
- key: K: key of the key-value pair to be added
- value: V: value of the key-value pair to be added
Returns:
- ?V: If the specified key already exists in the current map instance when this function is called, the old value of the key is returned. Otherwise, None is returned.
func clear()
func clear(): Unit
Description: Clears all key-value pairs.
func entryView(K)
func entryView(k: K): MapEntryView<K, V>
Description: Obtains the view corresponding to key k.
Parameters:
- k: K: key whose view is to be obtained
Returns:
- MapEntryView<K, V>: view corresponding to key k
func remove(K)
func remove(key: K): Option<V>
Description: Deletes the mapping (if any) of a specified key from a map instance.
Parameters:
- key: K: key to be deleted
Returns:
- Option<V>: value corresponding to the key to be removed from the map instance, which is encapsulated with Option
func remove(Collection<K>)
func remove(all!: Collection<K>): Unit
Description: Deletes the mapping (if any) of a specified collection from a mapping.
Parameters:
- all!: Collection<K>: collection to be deleted
func removeIf((K, V) -> Bool)
func removeIf(predicate: (K, V) -> Bool): Unit
Description: Passes a lambda expression. If the conditions are met, the corresponding key-value pair is deleted.
Parameters:
- predicate: (K, V) ->Bool: lambda expression used for judgment
func replace(K, V)
func replace(key: K, value: V): ?V
Description: If a specified key already exists in the current map instance, modifies the value of the key to the new value. Otherwise, no modification is required.
Parameters:
- key: K: key of the key-value pair to be modified
- value: V: new value of the key-value pair to be modified
Returns:
- ?V: If the specified key already exists in the current map, the old value of the key is returned. Otherwise, None is returned.
operator func [](K, V)
operator func [](key: K, value!: V): Unit
Description: Overloads the indexing operator. If a key exists, the new value overwrites the old value. If a key does not exist, the key-value pair is added.
Parameters:
- key: K: key to be set
- value!: V: value to be set
interface MapEntryView<K, V>
public interface MapEntryView<K, V> {
public prop key: K
public mut prop value: ?V
}
Description: Provides the view corresponding to a key in a mapping.
prop key
public prop key: K
Description: Returns a key in a view. If the key in the view is not in the original mapping, an empty view of the key is returned.
Type: K
prop value
public mut prop value: ?V
Description: Reads or modifies the value of the original mapping corresponding to a view.
If a non-empty value is set and the value of a view does not exist, an element is added to the original mapping corresponding to the view.
If the value is set to None, the current entry is deleted. After the deletion, the view can still be used.
Type: Option(V)
interface OrderedMap<K, V>
public interface OrderedMap<K, V> <: Map<K, V> {
public prop first: ?(K, V)
public prop last: ?(K, V)
public func removeFirst(): ?(K, V)
public func removeLast(): ?(K, V)
public func backward(mark: K, inclusive!: Bool): Iterator<(K, V)>
public func forward(mark: K, inclusive!: Bool): Iterator<(K, V)>
}
Description: Provides a method of mapping keys to values. The method supports using keys to find values, so it can be used to store and operate key-value pairs.
In an instance of the OrderedMap interface, the internal elements are ordered.
Parent types:
- Map<K, V>
prop first
public prop first: ?(K, V)
Description: Obtains the first element of an OrderedMap instance.
Type: Option<(K, V)>
prop last
public prop last: ?(K, V)
Description: Obtains the last element of an OrderedMap instance.
Type: Option<(K, V)>
func removeFirst()
public func removeFirst(): ?(K, V)
Description: Deletes the first element of an OrderedMap instance.
Returns:
- ?(K, V): If the current OrderedMap instance is not empty, the deleted key-value pair encapsulated with Option is returned. Otherwise,
Noneis returned.
func removeLast()
public func removeLast(): ?(K, V)
Description: Deletes the last element of an OrderedMap instance.
Returns:
- ?(K, V): If the current OrderedMap instance is not empty, the deleted key-value pair encapsulated with Option is returned. Otherwise,
Noneis returned.
func backward(K, Bool)
public func backward(mark: K, inclusive!: Bool): Iterator<(K, V)>
Description: Obtains the iterator that traverses from the first node whose key is less than or equal to mark to first in descending order. If the key of the node is equal to mark, whether the node corresponding to the key is included is determined based on inclusive!.
Parameters:
- mark: K: key used to determine where to start
- inclusive!: Bool: specifies whether to include mark as the start point when mark is the key of the first element of the iterator.
Returns:
- Iterator<(K, V)>: iterator
func forward(K, Bool)
public func forward(mark: K, inclusive!: Bool): Iterator<(K, V)>
Description: Obtains the iterator that traverses from the first node whose key is greater than or equal to mark to last in ascending order. If the key of the node is equal to mark, whether the node corresponding to the key is included is determined based on inclusive!.
Parameters:
- mark: K: key used to determine where to start
- inclusive!: Bool: specifies whether to include mark as the start point when mark is the key of the first element of the iterator.
Returns:
- Iterator<(K, V)>: iterator
interface OrderedSet<T>
public interface OrderedSet<T> <: Set<T> {
public prop first: ?T
public prop last: ?T
public func removeFirst(): ?T
public func removeLast(): ?T
public func backward(mark: T, inclusive!: Bool): Iterator<T>
public func forward(mark: T, inclusive!: Bool): Iterator<T>
}
Description: Provides operations related to a collection, allowing operations on internal elements in read/write mode.
In an instance of the OrderedSet interface, the internal elements are ordered.
Parent types:
- Set<T>
prop first
public prop first: ?T
Description: Obtains the first element of an OrderedSet instance.
Type: Option<T>
prop last
public prop last: ?T
Description: Obtains the last element of an OrderedSet instance.
Type: Option<T>
func removeFirst()
public func removeFirst(): ?T
Description: Deletes the first element of an OrderedSet instance.
Returns:
- ?T: If the current OrderedSet instance is not empty, the deleted element encapsulated with Option is returned. Otherwise,
Noneis returned.
func removeLast()
public func removeLast(): ?T
Description: Deletes the last element of an OrderedSet instance.
Returns:
- ?T: If the current OrderedSet instance is not empty, the deleted element encapsulated with Option is returned. Otherwise,
Noneis returned.
func backward(T, Bool)
public func backward(mark: T, inclusive!: Bool): Iterator<T>
Description: Obtains the iterator that traverses from the first node whose element is less than or equal to mark to first in descending order. If the element of the node is equal to mark, whether the node corresponding to the element is included is determined based on inclusive!.
Parameters:
- mark: T: element used to determine where to start
- inclusive!: Bool: specifies whether to include mark as the start point when mark is the first element of the iterator.
Returns:
- Iterator<T>: iterator
func forward(T, Bool)
public func forward(mark: T, inclusive!: Bool): Iterator<T>
Description: Obtains the iterator that traverses from the first node whose element is greater than or equal to mark to last in ascending order. If the element of the node is equal to mark, whether the node corresponding to the element is included is determined based on inclusive!.
Parameters:
- mark: T: element used to determine where to start
- inclusive!: Bool: specifies whether to include mark as the start point when mark is the first element of the iterator.
Returns:
- Iterator<T>: iterator
interface Queue<T>
public interface Queue<T> <: Collection<T> {
func add(element: T): Unit
func peek(): ?T
func remove(): ?T
}
Description: Specifies a queue data structure that complies with the first in first out (FIFO) principle. The Queue interface provides the following functions:
- Element addition: A specified last element can be added to a queue.
- Access: The first element of a queue can be accessed without being deleted.
- Deletion: The first element of a queue can be deleted.
- Operations supported for other collection types, such as operations involving the number of elements, null check, and iterator.
Parent types:
- Collection<T>
func add(T)
func add(element: T): Unit
Description: Adds a specified last element to a queue.
Parameters:
- element: T: element to be added to a queue
func peek()
func peek(): ?T
Description: Accesses the first element of a double-ended queue. This operation does not delete the first element.
Returns:
- ?T: value of the first element encapsulated with Option. If the double-ended queue is empty,
Noneis returned.
func remove()
func remove(): ?T
Description: Deletes the first element of a queue and returns the value of the element.
Returns:
- ?T: value of the deleted element encapsulated with Option. If the queue is empty,
Noneis returned.
interface ReadOnlyList<T>
public interface ReadOnlyList<T> <: Collection<T> {
prop first: ?T
prop last: ?T
func get(index: Int64): ?T
operator func [](index: Int64): T
}
Description: Defines a read-only list.
Parent types:
- Collection<T>
prop first
prop first: ?T
Description: Returns the first element in a list. If there is no first element, None is returned.
Type: Option<T>
prop last
prop last: ?T
Description: Returns the last element in a list. If there is no last element, None is returned.
Type: Option<T>
func get(Int64)
func get(index: Int64): ?T
Description: Returns an element at a specified position in a list.
Parameters:
- index: Int64: index of the element to be returned
Returns:
- ?T: element at the specified position. If index is less than 0 or greater than or equal to the number of elements in the list, None is returned.
operator func [](Int64)
operator func [](index: Int64): T
Description: Overloads the operator using get.
Parameters:
- index: Int64: index of the get interface
Returns:
- T: value of the element at the position specified by the index
interface ReadOnlyMap<K, V>
public interface ReadOnlyMap<K, V> <: Collection<(K, V)> {
func get(key: K): ?V
func contains(key: K): Bool
func contains(all!: Collection<K>): Bool
func keys(): EquatableCollection<K>
func values(): Collection<V>
operator func [](key: K): V
}
Description: Provides a method of mapping keys to values. The method supports using keys to find values, so it can be used to store key-value pairs.
A ReadOnlyMap instance cannot contain duplicate keys. Each key can be mapped to only one value.
Parent types:
- Collection<(K, V)>
func get(K)
func get(key: K): ?V
Description: Obtains the mapping value in a ReadOnlyMap instance according to a key.
Parameters:
- key: K: key used to obtain a value
Returns:
- ?V: value corresponding to the key in the ReadOnlyMap instance
func contains(K)
func contains(key: K): Bool
Description: Checks whether the mapping of a specified key is included.
Parameters:
- key: K: key to be checked
Returns:
- Bool: If the mapping is included, true is returned. Otherwise, false is returned.
func contains(Collection<K>)
func contains(all!: Collection<K>): Bool
Description: Checks whether the mappings of keys in a specified collection are included.
Parameters:
- all!: Collection<K>: collection of keys to be checked
Returns:
- Bool: If the mappings are included, true is returned. Otherwise, false is returned.
func keys()
func keys(): EquatableCollection<K>
Description: Returns all keys in a ReadOnlyMap instance and stores all the keys in a EquatableCollection<K> container.
Returns:
- EquatableCollection<K>: all keys stored
func values()
func values(): Collection<V>
Description: Returns all values in a ReadOnlyMap instance and stores all the values in a collection<V> container.
Returns:
- Collection<V>: all values stored
operator func [](K)
operator func [](key: K): V
Description: Overloads the indexing operator. If a key exists, the value corresponding to the key is returned. If a key does not exist, an exception is thrown.
Parameters:
- key: K: key to be searched for
Returns:
- V: value corresponding to the key
interface ReadOnlySet<T>
public interface ReadOnlySet<T> <: Collection<T> {
func contains(element: T): Bool
func contains(all!: Collection<T>): Bool
func subsetOf(other: ReadOnlySet<T>): Bool
}
Description: Provides operations related to a collection, allowing operations on internal elements in read-only mode.
Parent types:
- Collection<T>
func contains(T)
func contains(element: T): Bool
Description: Returns true if a collection contains a specified element.
Parameters:
- element: T: element to be checked
Returns:
- Bool: If the specified element is contained, true is returned. Otherwise, false is returned.
func contains(Collection<T>)
func contains(all!: Collection<T>): Bool
Description: Checks whether a collection contains another collection.
Parameters:
- all!: Collection<T>: another collection
Returns:
- Bool: If the collection contains the specified collection, true is returned. Otherwise, false is returned.
func subsetOf(ReadOnlySet<T>)
func subsetOf(other: ReadOnlySet<T>): Bool
Description: Checks whether a set is a subset of another set.
Parameters:
- other: ReadOnlySet<T>: another set
Returns:
- Bool: If the set is a subset of the specified set, true is returned. Otherwise, false is returned.
interface Set<T>
public interface Set<T> <: ReadOnlySet<T> {
func add(element: T): Bool
func add(all!: Collection<T>): Unit
func remove(element: T): Bool
func remove(all!: Collection<T>): Unit
func removeIf(predicate: (T) -> Bool): Unit
func clear(): Unit
func retain(all!: Set<T>): Unit
}
Description: Provides operations related to a collection, allowing operations on internal elements in read/write mode.
The set interface does not specify the internal implementation mode. In an instance of the set interface, the internal elements are usually unordered and cannot be accessed through indexes. In addition, the element addition order cannot be ensured.
Parent types:
- ReadOnlySet<T>
func add(T)
func add(element: T): Bool
Description: Adds an element. If the element already exists, it is not added.
Parameters:
- element: T: element to be added
Returns:
- Bool: If the element is added successfully, true is returned. Otherwise, false is returned.
func add(Collection<T>)
func add(all!: Collection<T>): Unit
Description: Adds all elements in a collection instance to a set instance. If elements to be added already exist in the latter, they are not added.
Parameters:
- all!: Collection<T>: collection of elements to be added
func remove(T)
func remove(element: T): Bool
Description: Removes a specified element (if any) from a collection.
Parameters:
- element: T: element to be deleted
Returns:
- Bool: If the specified element exists in the collection and is deleted successfully,
trueis returned. Otherwise,falseis returned.
func remove(Collection<T>)
func remove(all!: Collection<T>): Unit
Description: Removes all elements that are also contained in a specified collection instance from a set instance.
Parameters:
- all!: Collection<T>: collection<T> instance
func removeIf((T) -> Bool)
func removeIf(predicate: (T) -> Bool): Unit
Description: Passes a lambda expression. If the condition of predicate is met, the corresponding element is deleted.
Parameters:
- predicate: (T) ->Bool: lambda expression used for judgment
func clear()
func clear(): Unit
Description: Clears all key-value pairs.
func retain(Set<T>)
func retain(all!: Set<T>): Unit
Description: Retains only the elements in a set instance that are the same as those in the passed set instance.
Parameters:
- all!: Set<T>: set of elements to be retained
interface Stack<T>
public interface Stack<T> <: Collection<T> {
func add(element: T): Unit
func peek(): ?T
func remove(): ?T
}
Description: Specifies a stack that is a data structure following the last in first out (LIFO) principle. Addition and deletion can be performed at one end (called the stack top), while operations are not allowed at the other end (called the stack bottom).
Basic stack operations include adding a stack (add), removing a stack (remove), and checking the element on the top of a stack (peek).
Parent types:
- Collection<T>
func add(T)
func add(element: T): Unit
Description: Adds an element to a stack.
Parameters:
- element: T: element to be added to the top of the stack
func peek()
func peek(): ?T
Description: Checks the element at the top of a stack. This operation does not delete the element at the top of the stack.
Returns:
- ?T: element at the top of the stack. If the stack is empty,
Noneis returned.
func remove()
func remove(): ?T
Description: Deletes and returns the element at the top of a stack.
Returns:
- ?T: element at the top of the stack that is deleted. If the stack is empty,
Noneis returned.