|
|
@ -2,7 +2,7 @@ |
|
|
|
* Acedia provides a small set of collections for easier data storage. |
|
|
|
* Acedia provides a small set of collections for easier data storage. |
|
|
|
* This is their base class that provides a simple interface for |
|
|
|
* This is their base class that provides a simple interface for |
|
|
|
* common methods. |
|
|
|
* common methods. |
|
|
|
* Copyright 2020 - 2022 Anton Tarasenko |
|
|
|
* Copyright 2020-2023 Anton Tarasenko |
|
|
|
*------------------------------------------------------------------------------ |
|
|
|
*------------------------------------------------------------------------------ |
|
|
|
* This file is part of Acedia. |
|
|
|
* This file is part of Acedia. |
|
|
|
* |
|
|
|
* |
|
|
@ -25,18 +25,46 @@ class Collection extends AcediaObject |
|
|
|
var protected class<CollectionIterator> iteratorClass; |
|
|
|
var protected class<CollectionIterator> iteratorClass; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Method that must be overloaded for `GetItemByPointer()` to properly work. |
|
|
|
* Checks if caller `Collection` has value recorded with a given `key`. |
|
|
|
* |
|
|
|
* |
|
|
|
* This method must return an item that `key` refers to with it's |
|
|
|
* Not all collections must support all possible types of keys. |
|
|
|
* textual content (not as an object itself). |
|
|
|
* Key equality is determined by `AcediaObject::IsEqual()` method. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return `true` if caller `Collection` has value recorded with |
|
|
|
|
|
|
|
* a given `key` and `false` otherwise. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function bool HasKey(AcediaObject key); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Checks if caller `Collection` has value that a given `key` refers to with |
|
|
|
|
|
|
|
* its textual content (not as an object itself). |
|
|
|
* For example, `ArrayList` parses it into unsigned number, while |
|
|
|
* For example, `ArrayList` parses it into unsigned number, while |
|
|
|
* `HashTable` uses it as a key directly. |
|
|
|
* `HashTable` uses it as a key directly. |
|
|
|
|
|
|
|
* There is no requirement that all stored values must be reachable by |
|
|
|
|
|
|
|
* this method (i.e. `HashTable` only lets you access values with |
|
|
|
|
|
|
|
* `Text` keys). |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return `true` if caller `Collection` has value recorded with |
|
|
|
|
|
|
|
* a given `key` (understood within its textual content) and `false` |
|
|
|
|
|
|
|
* otherwise. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function bool HasKeyByText(Text key); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* This method must return an item that `key` refers to with its |
|
|
|
|
|
|
|
* textual content (not as an object itself). |
|
|
|
|
|
|
|
* For example, `ArrayList` parses it into unsigned number, while |
|
|
|
|
|
|
|
* `HashTable` uses it as a key directly. |
|
|
|
* There is no requirement that all stored values must be reachable by |
|
|
|
* There is no requirement that all stored values must be reachable by |
|
|
|
* this method (i.e. `HashTable` only lets you access values with |
|
|
|
* this method (i.e. `HashTable` only lets you access values with |
|
|
|
* `Text` keys). |
|
|
|
* `Text` keys). |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* To check whether such value even exists in the collection @see HasKeyByText. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param key Key that refers to the value to return. |
|
|
|
|
|
|
|
* @return Value that `key` refers to with its textual content. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected function AcediaObject GetByText(BaseText key); |
|
|
|
public function AcediaObject GetByText(Text key); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Creates an `Iterator` instance to iterate over stored items. |
|
|
|
* Creates an `Iterator` instance to iterate over stored items. |
|
|
@ -88,7 +116,7 @@ public function Empty() {} |
|
|
|
* this method (i.e. `HashTable` only lets you access values with `Text` keys). |
|
|
|
* this method (i.e. `HashTable` only lets you access values with `Text` keys). |
|
|
|
* |
|
|
|
* |
|
|
|
* @param jsonPointer Path, given by a JSON pointer. |
|
|
|
* @param jsonPointer Path, given by a JSON pointer. |
|
|
|
* @return An item `jsonPointerAsText` is referring to (according to the above |
|
|
|
* @return An item `jsonPointer` is referring to (according to the above |
|
|
|
* stated rules). `none` if such item does not exist. |
|
|
|
* stated rules). `none` if such item does not exist. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public final function AcediaObject GetItemByJSON(JSONPointer jsonPointer) |
|
|
|
public final function AcediaObject GetItemByJSON(JSONPointer jsonPointer) |
|
|
|