public abstract class KeyChain
extends java.lang.Object
implements java.util.Comparator
Key Type | Data Type |
---|---|
KEY_STRING | String |
KEY_INT | int |
KEY_LONG | long |
KEY_FLOAT | float |
KEY_DOUBLE | double |
KEY_TIME | time |
KEY_SEQUENCE | sequence number |
Modifier and Type | Field and Description |
---|---|
protected long |
ctime |
protected java.util.ArrayList<java.lang.Object> |
elements |
protected boolean |
isSorted |
static int |
KEY_DOUBLE |
static int |
KEY_FLOAT |
static int |
KEY_INT |
static int |
KEY_LONG |
static int |
KEY_SEQUENCE |
static int |
KEY_STRING |
static int |
KEY_TIME |
protected java.util.ArrayList<int[]> |
metadata |
protected long |
mtime |
protected int |
size |
protected long[] |
ts |
Constructor and Description |
---|
KeyChain(java.lang.String name,
int type,
int capacity) |
Modifier and Type | Method and Description |
---|---|
abstract int |
add(java.lang.Object key,
long mtime,
int[] meta,
java.lang.Object obj)
It adds the key and the object to the chain, and returns total number
of keys in the chain.
|
void |
clear()
It cleans up the chain.
|
abstract int |
compare(java.lang.Object a,
java.lang.Object b)
It compares thekeys of a and b in the ascending order
|
boolean |
equals(java.lang.Object o) |
protected void |
finalize() |
abstract int |
find(java.lang.Object key)
It looks for the given key in a sorted instance of KeyChain.
|
abstract java.lang.Object |
get(int i)
It returns the object of the key at the given index or null if the
index is out of bound.
|
int |
getCapacity()
returns capacity of the cache
|
long |
getCTime()
It returns the ctime of the chain
|
abstract java.lang.Object |
getKey(int i)
It returns the key in its data type at the given index or null if the
index is out of bound.
|
int |
getKeyType() |
abstract int[] |
getMetaData(int i)
It returns the metaData of the key at the given index or null if the
index is out of bound.
|
long |
getMTime()
It returns the mtime of the chain
|
java.lang.String |
getName() |
abstract long |
getTimestamp(int i)
It returns the timestamp for the object at the given index or -1
if the index is out of bound.
|
abstract int |
insert(java.lang.Object key,
long mtime,
int[] meta,
java.lang.Object obj)
It inserts the key and the object to the sorted chain and keeps the
sorted order.
|
abstract int |
locate(long currentTime,
int bakeTime)
It assumes the key chain has been sorted in ascending order.
|
int |
removable()
returns number of the objects whose keys have been removed
|
abstract java.lang.Object |
remove(int i)
It removes the key at the given index from the chain and disables its
metadata and the object so that they will not be available any more.
|
int |
size()
returns total number of the objects
|
abstract int |
sort()
It sorts the array of keys in ascending order.
|
abstract int |
truncate(int k)
It truncates the chain by deleting the first given number of keys
permanently and returns the number of keys deleted.
|
protected int size
protected long ctime
protected long mtime
protected boolean isSorted
protected long[] ts
protected java.util.ArrayList<java.lang.Object> elements
protected java.util.ArrayList<int[]> metadata
public static final int KEY_STRING
public static final int KEY_INT
public static final int KEY_LONG
public static final int KEY_FLOAT
public static final int KEY_DOUBLE
public static final int KEY_TIME
public static final int KEY_SEQUENCE
public int getCapacity()
public int size()
public int removable()
public java.lang.String getName()
public int getKeyType()
public long getCTime()
public long getMTime()
public abstract int add(java.lang.Object key, long mtime, int[] meta, java.lang.Object obj)
public abstract int insert(java.lang.Object key, long mtime, int[] meta, java.lang.Object obj)
public abstract java.lang.Object remove(int i)
public abstract java.lang.Object get(int i)
public abstract long getTimestamp(int i)
public abstract int[] getMetaData(int i)
public abstract java.lang.Object getKey(int i)
public abstract int find(java.lang.Object key)
public abstract int sort()
public abstract int locate(long currentTime, int bakeTime)
public abstract int truncate(int k)
public void clear()
protected void finalize()
finalize
in class java.lang.Object
public abstract int compare(java.lang.Object a, java.lang.Object b)
compare
in interface java.util.Comparator
public boolean equals(java.lang.Object o)
equals
in interface java.util.Comparator
equals
in class java.lang.Object