RegisterSign In

API Documentation: Class OrderedList64Bit

Package: com.mckoi.data
implements com.mckoi.data.Index64Bit

An ordered list of 64 bit values mapped over a DataFile object. When list modifications happen, the change is immediately mapped into into the underlying data file. This object grows and shrinks the size of the underlying data file as values are inserted and removed from the list.

This class is an implementation of Index64Bit.

This class offers a practical way of representing a sorted index of objects within a database. The collation of the list items can be defined via the IndexObjectCollator interface, or the order may be defined as a function of the index value itself, as per the Index64Bit contract.

This list object supports containing duplicate values.

Constructors Summary

OrderedList64Bit(DataFile data, boolean immutable_source)
OrderedList64Bit(DataFile data)

Methods Summary

void clear()
void clear(long pos, long size)
long size()
long searchFirst(Object value, IndexObjectCollator c)
long searchLast(Object value, IndexObjectCollator c)
long get(long position)
Iterator64Bit iterator(long start, long end)
Iterator64Bit iterator()
void insert(Object value, long ref, IndexObjectCollator c)
boolean insertUnique(Object value, long ref, IndexObjectCollator c)
void remove(Object value, long ref, IndexObjectCollator c)
void add(long ref)
void insert(long ref, long pos)
long remove(long pos)
void insertSortKey(long ref)
void removeSortKey(long ref)
boolean containsSortKey(long ref)

Constructor Details

OrderedList64Bit(DataFile data, boolean immutable_source)

Constructs the list wrapped to the given DataFile. If immutable_source is true, the object will fail if any mutation is attempted on the list.

OrderedList64Bit(DataFile data)

Same as the above constructor, only immutable_source is false by default.

Method Details

void clear()

Clears the index of all values.

void clear(long pos, long size)

Clears the index of size number of values from the given position.

long size()

Returns the total number of elements in the index.

long searchFirst(Object value, IndexObjectCollator c)

Assuming the index is ordered, searches for the first instance of the specified value within the index and returns the position of the first value, or returns -(position + 1) if the specified value is not found and position is the place where the value would be inserted to maintain index integrity (sort order).

The correct operation of this function depends on the index maintaining a consistent order through its lifetime. If the collation characteristics change then the result of this function is undefined.

long searchLast(Object value, IndexObjectCollator c)

Assuming the index is ordered, searches for the last instance of the specified value within the index and returns the position of the last value, or returns -(position + 1) if the specified value is not found and position is the place where the value would be inserted to maintain index integrity (sort order).

The correct operation of this function depends on the index maintaining a consistent order through its lifetime. If the collation characteristics change then the result of this function is undefined.

long get(long position)

Returns the 64 bit element at the given position in the index. This uses the DataFile 'position' function to address the value.

Iterator64Bit iterator(long start, long end)

Returns a Iterator64Bit that is limited between the boundaries specified and allows for the access of all elements in the subset if the index.

IMPORTANT: While an iterator exists we assume that no modifications will be made to the index. If the index changes while an iterator is active the behavior is unspecified.

Iterator64Bit iterator()

Returns a Iterator64Bit that is setup to iterate the entire index from start to end.

IMPORTANT: While an iterator exists we assume that no modifications will be made to the index. If the index changes while an iterator is active the behavior is unspecified.

void insert(Object value, long ref, IndexObjectCollator c)

Inserts a 64-bit element, ref, into the index at the ordered position. If there are elements in the index that are the same value as the one being inserted, the element is inserted after the end of the group of equal elements in the set.

The correct operation of this function depends on the index maintaining a consistent order through its lifetime. If the collation characteristics change then the result of this function is undefined.

boolean insertUnique(Object value, long ref, IndexObjectCollator c)

Inserts a 64-bit element, ref, into the index at the ordered position. If there there are elements in the index that are the same value as the one being inserted, the method returns false and does not change the list.

The correct operation of this function depends on the index maintaining a consistent order through its lifetime. If the collation characteristics change then the result of this function is undefined.

void remove(Object value, long ref, IndexObjectCollator c)

Removes a 64-bit element, ref, from the index at the ordered position. If there are multiple elements in the index with the same value, the first element is removed.

The correct operation of this function depends on the index maintaining a consistent order through its lifetime. If the collation characteristics change then the result of this function is undefined.

void add(long ref)

Adds a 64-bit value to the end of the index ignoring any ordering scheme that may have previously been used to insert values into the index. This is a useful efficiency for the common case when the order of values is already known.

void insert(long ref, long pos)

Inserts a 64-bit value at the given position in the list shifting any values after the position forward by one position.

long remove(long pos)

Removes a 64-bit value from the given position in the list shifting any values after the position backwards by one position. Generates an exception if pos is out of range or the value could not be removed for another reason (such as the structure being read-only).

void insertSortKey(long ref)

Inserts a 64-bit value at an ordered position in the index where the order is the ascending collation of the 64-bit values. For example, inserting 6 into the list { 1, 3, 7, 9 } would result in the list { 1, 3, 6, 7, 9 }.

The correct operation of this function depends on the index maintaining a consistent order through its lifetime. If the collation characteristics change then the result of this function is undefined.

void removeSortKey(long ref)

Removes the first 64-bit value from the order position in the index where the order is the ascending collation of the 64-bit values. Generates an exception if the value is not found in the index.

The correct operation of this function depends on the index maintaining a consistent order through its lifetime. If the collation characteristics change then the result of this function is undefined.

boolean containsSortKey(long ref)

Returns true if the set contains the given 64-bit value assuming the order of the set is the ascending collation of the 64-bit values. Returns false if the value was not found.

The correct operation of this function depends on the index maintaining a consistent order through its lifetime. If the collation characteristics change then the result of this function is undefined.

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.