|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.sido.common.AnnotatedSupport
net.sf.sido.array.Array<T>
net.sf.sido.array.IndexedArray<T,K>
T - Type of elements in the arrayK - Type of indexpublic final class IndexedArray<T,K>
Array sub-class that indexes its elements using an indexer function
| Constructor Summary | |
|---|---|
protected |
IndexedArray(Collection<T> elements,
ArrayEvent<T> event,
com.google.common.base.Function<? super T,K> indexer)
Internal constructor used to create indexed arrays with their array events. |
|
IndexedArray(com.google.common.base.Function<? super T,K> indexer,
Array<T> elements)
Builds an indexed array from another array. |
|
IndexedArray(com.google.common.base.Function<? super T,K> indexer,
Collection<T> elements)
Builds an indexed array from a collection. |
|
IndexedArray(com.google.common.base.Function<? super T,K> indexer,
T... elements)
Builds an indexed array from an array. |
| Method Summary | ||
|---|---|---|
IndexedArray<T,K> |
add(Array<T> elements)
Appends elements |
|
IndexedArray<T,K> |
add(Collection<T> elements)
Appends elements |
|
IndexedArray<T,K> |
add(T... elements)
Appends elements |
|
protected void |
checkKeys(Collection<T> elements)
Checks that keys are unique |
|
protected Array<T> |
createNewArray(List<T> newList,
ArrayEvent<T> tArrayEvent)
Creation of an IndexedArray by update/add/delete operations. |
|
IndexedArray<T,K> |
delete(int... indexes)
Deletes one or several elements using their indexes. |
|
IndexedArray<T,K> |
filter(com.google.common.base.Predicate<T> tPredicate)
Filters the array using a predicate |
|
IndexedArray<T,K> |
filterOnKeys(com.google.common.base.Predicate<K> predicate)
Filter this array using a predicate on the keys |
|
T |
getByIndex(K key)
Gets an element by its key |
|
com.google.common.base.Function<? super T,K> |
getIndexer()
Returns the indexer function which is used by the indexed array. |
|
Array<K> |
getKeyArray()
Returns all keys as an array |
|
List<K> |
getKeyList()
Returns a list of keys, ordered the same way of the items. |
|
Set<K> |
getKeys()
Returns all keys as a set |
|
IndexedArray<T,K> |
insert(int position,
Collection<T> elements)
Appends elements at a given position |
|
IndexedArray<T,K> |
insert(int position,
T... items)
Appends elements at a given position |
|
IndexedArray<T,K> |
reverse()
Creates a reversed version of this array |
|
IndexedArray<T,K> |
sub(int startIndex,
int endIndex)
Sub array using a range between two indexes. |
|
String |
toString()
String representation. |
|
|
transform(com.google.common.base.Function<? super T,V> valueTransform,
com.google.common.base.Function<? super V,L> newIndexer)
Transforms this indexed array by transforming the values and re-indexing them using a new indexer function. |
|
IndexedArray<T,K> |
update(int index,
T newElement)
Updates an element with a new value |
|
| Methods inherited from class net.sf.sido.array.Array |
|---|
empty, equals, get, getArrayEvent, getAt, getLength, getOrNull, hashCode, index, isEmpty, iterator, length, size, toList, transform |
| Methods inherited from class net.sf.sido.common.AnnotatedSupport |
|---|
getAnnotation, putAnnotation |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public IndexedArray(com.google.common.base.Function<? super T,K> indexer,
Array<T> elements)
indexer - Indexer to useelements - Source array
public IndexedArray(com.google.common.base.Function<? super T,K> indexer,
Collection<T> elements)
indexer - Indexer to useelements - Source collection
public IndexedArray(com.google.common.base.Function<? super T,K> indexer,
T... elements)
indexer - Indexer to useelements - Source array
protected IndexedArray(Collection<T> elements,
ArrayEvent<T> event,
com.google.common.base.Function<? super T,K> indexer)
elements - Source elementsevent - Array event that created this arrayindexer - Indexer to use| Method Detail |
|---|
public com.google.common.base.Function<? super T,K> getIndexer()
public T getByIndex(K key)
key - Key
null)public Array<K> getKeyArray()
public Set<K> getKeys()
public List<K> getKeyList()
public IndexedArray<T,K> filterOnKeys(com.google.common.base.Predicate<K> predicate)
predicate - Predicate to use on the keys
public <V,L> IndexedArray<V,L> transform(com.google.common.base.Function<? super T,V> valueTransform,
com.google.common.base.Function<? super V,L> newIndexer)
V - Type of the new valuesL - Type of the new keysvalueTransform - Transform function for the valuesnewIndexer - Indexer for the new values
protected Array<T> createNewArray(List<T> newList,
ArrayEvent<T> tArrayEvent)
createNewArray in class Array<T>newList - List of elementstArrayEvent - Associated array of events
public IndexedArray<T,K> add(Array<T> elements)
Array
add in class Array<T>elements - Array of elements to add
Array, that contains this array's elements, plus the ones in
elementspublic IndexedArray<T,K> add(Collection<T> elements)
Array
add in class Array<T>elements - Collection of elements to add
Array, that contains this array's elements, plus the ones in
elementspublic IndexedArray<T,K> add(T... elements)
Array
add in class Array<T>elements - Array of elements to add
Array, that contains this array's elements, plus the ones in
elementspublic IndexedArray<T,K> delete(int... indexes)
Arrayindexes array
does not need to be sorted.
delete in class Array<T>indexes - List of indexes to remove from the array.
Array the elements have been removed from. This new array will be
associated with an ArrayEvent that describes the deletion.public IndexedArray<T,K> filter(com.google.common.base.Predicate<T> tPredicate)
Array
filter in class Array<T>tPredicate - Function that returns true for the elements that must be kept
Array the elements have been removed from. This new array will be
associated with an ArrayEvent that describes the deletion.
public IndexedArray<T,K> insert(int position,
T... items)
Array
insert in class Array<T>position - Position in the array to insert the new elements atitems - List of elements to insert at this position
Array where the elements have been inserted into. This new array will
be associated with an ArrayEvent that describes the insertion.
public IndexedArray<T,K> sub(int startIndex,
int endIndex)
Array
sub in class Array<T>startIndex - Start indexendIndex - End index
Array instance that comprises only the elements between
startIndex and endIndex. An ArrayEvent is
associated with this array, which describes the operation.List.subList(int, int)
public IndexedArray<T,K> update(int index,
T newElement)
Array
update in class Array<T>index - Index to update the element atnewElement - Element to replace the initial element with
Array where the elements have been updated. This new array will be
associated with an ArrayEvent that describes the update.public IndexedArray<T,K> reverse()
Array
reverse in class Array<T>Collections.reverse(java.util.List)
public IndexedArray<T,K> insert(int position,
Collection<T> elements)
Array
insert in class Array<T>position - Position in the array to insert the new elements atelements - List of elements to insert at this position
Array where the elements have been inserted into. This new array will
be associated with an ArrayEvent that describes the insertion.protected void checkKeys(Collection<T> elements)
public String toString()
Array
toString in class Array<T>List#toString()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||