Collection operations
These operations are useful for dealing with collection objects, such as Array, Map or Set objects.
All of these operations may raise direct or normal exceptions. They always check the validity of their arguments and raise exceptions on any error conditions.
See also: There are faster but more specific operations for dealing with only Array objects, described in section Array operations.
- Assize_t ALen(AThread *t, AValue collection)
- Call the length() method of the argument, and return the value converted to a C integer. Raise std::TypeError if the return value is not an Int object. If a normal exception was raised, return a negative value.
- AValue AGetItem(AThread *t, AValue collection, AValue index)
- Return collection[index], i.e. the result of the _get method of collection. This method may return AError.
- AValue ASetItem(AThread *t, AValue collection, AValue index, AValue object)
- Assign object to collection[index], i.e. call the _set method of collection. The return value is ANil, if successful, or AError.
- AValue AGetItemAt(AThread *t, AValue collection, Assize_t index)
- Return collection[index] after converting index to an Int object, i.e. the result of the _get method of collection. This is a convenience method that can be used instead of AGetItem if the index is a C integer. This method may return AError.
- AValue ASetItemAt(AThread *t, AValue collection, Assize_t index, AValue object)
- Assign object to collection[index] after converting index to an Int object, i.e. call the _set method of collection. This is a convenience function that can be used instead of ASetItem if the index is a C integer. The return value is ANil, if successful, or AError.
- AValue AIterator(AThread *t, AValue object)
- Return the result of calling the iterator() method of an object. This is typically an iterator object. This function may return AError.
- int ANext(AThread *t, AValue iter, AValue *next)
- If iter is an iterator and it has items left, store the next value in the iteration in *next and return 1. If there are no items left, return 0. If there was an error, return -1.
- int AIn(AThread *t, AValue object, AValue collection)
- Check if an object is contained in a collection, similar to using the in operator. Return 1 for true, 0 for false and -1 for error.