Package ubic.gemma.core.datastructure
Class SparseArrayList<T>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<T>
-
- ubic.gemma.core.datastructure.SparseArrayList<T>
-
- Type Parameters:
T
- the type of elements in the array
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
,List<T>
,SparseList<T>
public class SparseArrayList<T> extends AbstractList<T> implements SparseList<T>
A sparse array backed by anArrayList
.This array uses a common encoding for sparse encoding such as CSR and CSC. Data points are stored in two vectors: elements and indices. To make operations efficient, the indices are kept in-order.
- Author:
- poirigui
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description SparseArrayList()
Create an empty sparse array.SparseArrayList(Collection<T> collection)
Create a new sparse array from a given collection,null
is used as default value.SparseArrayList(Collection<T> collection, T defaultValue)
SparseArrayList(List<T> array, int[] indices, int numberOfElements)
Create a new sparse array,null
is used as default value.SparseArrayList(List<T> array, int[] indices, int numberOfElements, T defaultValue)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
T
get(int i)
int
indexOf(Object o)
int
lastIndexOf(Object o)
int
size()
int
storageSize()
The number of elements actually stored.-
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, hashCode, iterator, listIterator, listIterator, remove, removeRange, set, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
-
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, hashCode, isEmpty, iterator, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, sort, spliterator, subList, toArray, toArray
-
-
-
-
Constructor Detail
-
SparseArrayList
public SparseArrayList(Collection<T> collection, T defaultValue)
-
SparseArrayList
public SparseArrayList(Collection<T> collection)
Create a new sparse array from a given collection,null
is used as default value.
-
SparseArrayList
public SparseArrayList(List<T> array, int[] indices, int numberOfElements, T defaultValue)
-
SparseArrayList
public SparseArrayList(List<T> array, int[] indices, int numberOfElements)
Create a new sparse array,null
is used as default value.
-
SparseArrayList
public SparseArrayList()
Create an empty sparse array.
-
-
Method Detail
-
get
public T get(int i)
-
storageSize
public int storageSize()
Description copied from interface:SparseList
The number of elements actually stored.- Specified by:
storageSize
in interfaceSparseList<T>
-
size
public int size()
- Specified by:
size
in interfaceCollection<T>
- Specified by:
size
in interfaceList<T>
- Specified by:
size
in classAbstractCollection<T>
-
indexOf
public int indexOf(Object o)
-
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOf
in interfaceList<T>
- Overrides:
lastIndexOf
in classAbstractList<T>
-
equals
public boolean equals(Object o)
- Specified by:
equals
in interfaceCollection<T>
- Specified by:
equals
in interfaceList<T>
- Overrides:
equals
in classAbstractList<T>
-
-