with a few extensions:
- Semi-immutable, e.g. once added, cannot be removed.
- Assumes sequence of values added are in sorted order
-
indexOf(Object) return value conforms to the contract of Arrays.binarySearch(Object[], Object)
-
seal() is introduce to trim the List size, similar to ArrayList.trimToSize(), once it is called, no add should be performed.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_type
protected Class<T> _type
_innerList
protected List<?> _innerList
TermValueList
protected TermValueList()
TermValueList
protected TermValueList(int capacity)
buildPrimitiveList
protected abstract List<?> buildPrimitiveList(int capacity)
format
public abstract String format(Object o)
seal
public abstract void seal()
getInnerList
public List<?> getInnerList()
- The user of this method should not try to alter the content of the list,
which may result in data inconsistency.
And of the content can be accessed using the getRawValue(int) method.
- Returns:
- the inner list
add
public abstract boolean add(String o)
- Add a new value to the list. It is important to add the values in sorted (ASC) order.
Our algorithm uses binary searches and priority queues, both of which fails when the ordering is wrong.
- Specified by:
add in interface Collection<String>- Specified by:
add in interface List<String>
add
public void add(int index,
String element)
- Specified by:
add in interface List<String>
addAll
public boolean addAll(Collection<? extends String> c)
- Specified by:
addAll in interface Collection<String>- Specified by:
addAll in interface List<String>
addAll
public boolean addAll(int index,
Collection<? extends String> c)
- Specified by:
addAll in interface List<String>
clear
public void clear()
- Specified by:
clear in interface Collection<String>- Specified by:
clear in interface List<String>
contains
public boolean contains(Object o)
- Specified by:
contains in interface Collection<String>- Specified by:
contains in interface List<String>
containsWithType
public abstract boolean containsWithType(T val)
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll in interface Collection<String>- Specified by:
containsAll in interface List<String>
getType
public Class<T> getType()
get
public String get(int index)
- Specified by:
get in interface List<String>
getRawValue
public T getRawValue(int index)
indexOf
public abstract int indexOf(Object o)
- Specified by:
indexOf in interface List<String>
indexOfWithOffset
public int indexOfWithOffset(Object value,
int offset)
indexOfWithType
public abstract int indexOfWithType(T o)
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty in interface Collection<String>- Specified by:
isEmpty in interface List<String>
iterator
public Iterator<String> iterator()
- Specified by:
iterator in interface Iterable<String>- Specified by:
iterator in interface Collection<String>- Specified by:
iterator in interface List<String>
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOf in interface List<String>
listIterator
public ListIterator<String> listIterator()
- Specified by:
listIterator in interface List<String>
listIterator
public ListIterator<String> listIterator(int index)
- Specified by:
listIterator in interface List<String>
remove
public boolean remove(Object o)
- Specified by:
remove in interface Collection<String>- Specified by:
remove in interface List<String>
remove
public String remove(int index)
- Specified by:
remove in interface List<String>
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll in interface Collection<String>- Specified by:
removeAll in interface List<String>
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll in interface Collection<String>- Specified by:
retainAll in interface List<String>
set
public String set(int index,
String element)
- Specified by:
set in interface List<String>
size
public int size()
- Specified by:
size in interface Collection<String>- Specified by:
size in interface List<String>
subList
public List<String> subList(int fromIndex,
int toIndex)
- Specified by:
subList in interface List<String>
toArray
public Object[] toArray()
- Specified by:
toArray in interface Collection<String>- Specified by:
toArray in interface List<String>
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArray in interface Collection<String>- Specified by:
toArray in interface List<String>
main
public static void main(String[] args)
Copyright © 2011. All Rights Reserved.