RegisterSign In

API Documentation: Interface ODBList

Package: com.mckoi.odb
implements java.lang.Iterable<com.mckoi.odb.ODBObject>

An ordered set of items, either sorted by the 128-bit reference value of the items in the list, or by an order specification based on a key value of the item. An ODBList is a useful element to create a database index, or to reference a variable set of associated items in an object.

ODBList must support fast iteration and index addressing. ODBList must also support views via the 'sub', 'head' and 'tail' methods.

An implementation of ODBList may put constraints on items stored in the list, such as not allowing duplicate values of the same item or key value to be inserted into the list. Such constraints are enforced both when the list is immediately mutated by the client and also when a transaction is committed, at which time the activity of concurrent transactions are considered.

Methods Summary

ODBClass getElementClass()
long size()
boolean isEmpty()
Reference first()
Reference last()
ODBListIterator iterator()
void add(Reference ref) throws ConstraintViolationException
void add(ODBObject value) throws ConstraintViolationException
boolean remove(Reference ref)
boolean removeAll(Reference ref)
boolean contains(Reference ref)
Reference get(long index)
ODBObject getObject(long index)
long indexOf(Reference ref)
long lastIndexOf(Reference ref)
ODBList sub(Reference from_ref, Reference to_ref)
ODBList tail(Reference from_ref)
ODBList head(Reference to_ref)
boolean remove(String key_value)
boolean removeAll(String key_value)
boolean contains(String key_value)
Reference get(String key_value)
ODBObject getObject(String key_value)
long indexOf(String key_value)
long lastIndexOf(String key_value)
ODBList sub(String from_key, String to_key)
ODBList tail(String from_key)
ODBList head(String to_key)

Method Details

ODBClass getElementClass()

Returns the class of the elements stored in this list.

long size()

Returns the size of the list.

boolean isEmpty()

Returns true if the list is empty.

Reference first()

Returns the first reference stored in this list.

Reference last()

Returns the last reference stored in this list.

ODBListIterator iterator()

Returns an iterator over references in this list.

void add(Reference ref)

Adds a new element to the list at the ordered position in the list. The referenced element must match the class returned by 'getElementClass()'. Throws a constraint violation exception if the entry could not be added.

void add(ODBObject value)

Adds the object element to the list at the ordered position in the list. The object must match the class returned by 'getElementClass()'. Throws a constraint violation exception if the entry could not be added.

boolean remove(Reference ref)

Removes the first element from the list that matches the reference. The referenced object must be stored in this list.

If an entry with the given reference is not found returns false, otherwise returns true. Note that if the list contains duplicates, this will only remove the first. Use 'removeAll' to remove all the entries with the given reference.

boolean removeAll(Reference ref)

Removes all the elements from the list of the given reference.

If there are no entries in the list with the given reference then false is returned. This is equivalent to the 'remove' function for lists that do not allow duplicates.

boolean contains(Reference ref)

Returns true if the list contains at least one element with the given reference.

Reference get(long index)

Returns the reference stored at the given position in this list.

ODBObject getObject(long index)

Returns the reference stored at the given position as an ODBObject.

long indexOf(Reference ref)

Returns the index of the first reference that matches 'ref' in the list, or -(pos + 1) if no entries with the reference are found where pos is index the entry with that reference would be found.

long lastIndexOf(Reference ref)

Returns the index of the last reference that matches 'ref' in the list, or -(pos + 1) if no entries with the reference are found where pos is index the entry with that reference would be found.

This is equivalent to 'indexOf' for lists that do not allow duplicates.

ODBList sub(Reference from_ref, Reference to_ref)

Returns an ODBList that is a subset of this list between the given positions.

ODBList tail(Reference from_ref)

Returns an ODBList that is a subset of this list between the given position and the end of the list.

ODBList head(Reference to_ref)

Returns an ODBList that is a subset of this list between the start of the list and the given position.

boolean remove(String key_value)

Removes the first element from the list that has a key that matches the given string. This only works if the order specification is on the key of stored objects.

If an entry with the given key is not found returns false, otherwise returns true. Note that if the list contains duplicates, this will only remove the first. Use 'removeAll' to remove all the entries with the given key value.

boolean removeAll(String key_value)

Removes all the elements from the list that have the given key. This only works if the order specification is on the key of stored objects.

If there are no entries in the list with the key value then false is returned. This is equivalent to the 'remove' function for lists that do not allow duplicates.

boolean contains(String key_value)

Returns true if the list contains at least one element with the given key value. This only works if the order specification is on the key of stored objects.

Reference get(String key_value)

Returns a reference to the first entry in the list that contains the given key value. This only works if the order specification is on the key of stored objects.

ODBObject getObject(String key_value)

Returns the first entry in the list that contains the given key value. This only works if the order specification is on the key of stored objects.

long indexOf(String key_value)

Returns the index of the first element that contains the key value in the list, or -(pos + 1) if no entries with the key value are found where pos is the index the entry with that key value would be found.

long lastIndexOf(String key_value)

Returns the index of the last element that contains the key value in the list, or -(pos + 1) if no entries with the key value are found where pos is the index the entry with that key value would be found.

ODBList sub(String from_key, String to_key)

Returns an ODBList that is a subset of this list between the given positions.

ODBList tail(String from_key)

Returns an ODBList that is a subset of this list between the given position and the end of the list.

ODBList head(String to_key)

Returns an ODBList that is a subset of this list between the start of the list and the given position.

The text on this page is licensed under the Creative Commons Attribution 3.0 License. Java is a registered trademark of Oracle and/or its affiliates.
Mckoi is Copyright © 2000 - 2020 Diehl and Associates, Inc. All rights reserved.