public class ArrayModifiableIntegerDBIDs extends Object implements ArrayModifiableDBIDs, IntegerArrayDBIDs
Modifier and Type | Class and Description |
---|---|
private class |
ArrayModifiableIntegerDBIDs.Itr
Iterator class.
|
private class |
ArrayModifiableIntegerDBIDs.Slice
Slice of an array.
|
Modifier and Type | Field and Description |
---|---|
static int |
INITIAL_SIZE
Initial size.
|
private int |
size
Occupied size.
|
private int[] |
store
The actual Trove array list.
|
Modifier | Constructor and Description |
---|---|
protected |
ArrayModifiableIntegerDBIDs()
Constructor.
|
protected |
ArrayModifiableIntegerDBIDs(DBIDs existing)
Constructor.
|
protected |
ArrayModifiableIntegerDBIDs(int isize)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(DBIDRef e)
Add a single DBID to the collection.
|
boolean |
addDBIDs(DBIDs ids)
Add DBIDs to collection.
|
void |
assignVar(int index,
DBIDVar var)
Assign a DBID variable the value of position
index . |
int |
binarySearch(DBIDRef key)
Search for the position of the given key, assuming that the data set is
sorted.
|
void |
clear()
Clear this collection.
|
boolean |
contains(DBIDRef o)
Test whether an ID is contained.
|
private void |
ensureSize(int minsize)
Resize as desired.
|
DBID |
get(int i)
Get the i'th entry (starting at 0)
If possible, use an
DBIDArrayIter via ArrayDBIDs.iter() instead! |
private void |
grow()
Grow array by 50%.
|
boolean |
isEmpty()
Test for an empty DBID collection.
|
ArrayModifiableIntegerDBIDs.Itr |
iter()
Get a modifiable DBID iterator (a more efficient API).
|
boolean |
remove(DBIDRef o)
Remove a single DBID from the collection.
|
DBID |
remove(int index)
Remove the i'th entry (starting at 0)
|
boolean |
removeDBIDs(DBIDs ids)
Remove DBIDs from collection.
|
DBID |
set(int index,
DBIDRef element)
Replace the i'th entry (starting at 0)
|
int |
size()
Retrieve the collection / data size.
|
ArrayModifiableIntegerDBIDs.Slice |
slice(int begin,
int end)
Slice a subarray (as view, not copy!)
|
void |
sort()
Sort the DBID set.
|
void |
sort(Comparator<? super DBIDRef> comparator)
Sort the DBID set.
|
void |
sort(int start,
int end,
Comparator<? super DBIDRef> comparator)
Sort the DBID set.
|
void |
swap(int a,
int b)
Swap DBIDs add positions a and b.
|
private int[] store
private int size
public static final int INITIAL_SIZE
protected ArrayModifiableIntegerDBIDs(int isize)
isize
- Initial sizeprotected ArrayModifiableIntegerDBIDs()
protected ArrayModifiableIntegerDBIDs(DBIDs existing)
existing
- Existing idspublic int size()
DBIDs
size
in interface ArrayDBIDs
size
in interface DBIDs
public boolean isEmpty()
DBIDs
public DBID get(int i)
ArrayDBIDs
DBIDArrayIter
via ArrayDBIDs.iter()
instead!get
in interface ArrayDBIDs
i
- Indexpublic void assignVar(int index, DBIDVar var)
ArrayDBIDs
index
.assignVar
in interface ArrayDBIDs
index
- Positionvar
- Variable to assign the value to.private void ensureSize(int minsize)
minsize
- Desired sizeprivate void grow()
public boolean addDBIDs(DBIDs ids)
ModifiableDBIDs
addDBIDs
in interface ModifiableDBIDs
ids
- IDs to add.true
when modifiedpublic boolean removeDBIDs(DBIDs ids)
ModifiableDBIDs
removeDBIDs
in interface ModifiableDBIDs
ids
- IDs to remove.true
when modifiedpublic boolean add(DBIDRef e)
ModifiableDBIDs
add
in interface ModifiableDBIDs
e
- ID to addpublic boolean remove(DBIDRef o)
ModifiableDBIDs
remove
in interface ModifiableDBIDs
o
- ID to removepublic DBID set(int index, DBIDRef element)
ArrayModifiableDBIDs
set
in interface ArrayModifiableDBIDs
index
- Indexelement
- New valuepublic DBID remove(int index)
ArrayModifiableDBIDs
remove
in interface ArrayModifiableDBIDs
index
- Indexpublic void clear()
ModifiableDBIDs
clear
in interface ModifiableDBIDs
public int binarySearch(DBIDRef key)
ArrayDBIDs
-(1+insertion position)
is returned, as
for Java Collections.binarySearch(java.util.List<? extends java.lang.Comparable<? super T>>, T)
binarySearch
in interface ArrayDBIDs
key
- Key to search forpublic boolean contains(DBIDRef o)
DBIDs
public void sort()
ArrayModifiableDBIDs
sort
in interface ArrayModifiableDBIDs
public void sort(Comparator<? super DBIDRef> comparator)
ArrayModifiableDBIDs
sort
in interface ArrayModifiableDBIDs
comparator
- Comparator to usepublic void sort(int start, int end, Comparator<? super DBIDRef> comparator)
ArrayModifiableDBIDs
sort
in interface ArrayModifiableDBIDs
start
- Starting index, for partial sortingend
- End index, for partial sorting (exclusive)comparator
- Comparator to usepublic void swap(int a, int b)
ArrayModifiableDBIDs
swap
in interface ArrayModifiableDBIDs
a
- First positionb
- Second positionpublic ArrayModifiableIntegerDBIDs.Slice slice(int begin, int end)
ArrayDBIDs
slice
in interface ArrayDBIDs
slice
in interface IntegerArrayDBIDs
begin
- Begin (inclusive)end
- End (exclusive)public ArrayModifiableIntegerDBIDs.Itr iter()
ModifiableDBIDs
for(DBIDMIter iter = ids.iter(); iter.valid(); iter.advance()) {
DBID id = iter.getDBID();
iter.remove();
}
iter
in interface ArrayDBIDs
iter
in interface ArrayModifiableDBIDs
iter
in interface DBIDs
iter
in interface IntegerArrayDBIDs
iter
in interface IntegerDBIDs
iter
in interface ModifiableDBIDs