Package com.complexible.common.collect
Class BigArrayList<T>
- java.lang.Object
-
- com.complexible.common.collect.BigArrayList<T>
-
- Type Parameters:
T
-
- All Implemented Interfaces:
java.lang.Iterable<T>
public final class BigArrayList<T> extends java.lang.Object implements java.lang.Iterable<T>
Simple implementation of a list that can have more than Integer.MAX_VALUE values. Works as a normal
ArrayList
until the size gets bigger than Integer.MAX_VALUE. After that, it works as aList
ofArrayList
s, soget(long)
will be a little bit more expensive.For now, only
add(Object)
,get(long)
, andsize()
are supported.- Since:
- 2.0
- Version:
- 2.0
- Author:
- Pedro Oliveira
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_SIZE
The default max size aList
can have
-
Constructor Summary
Constructors Constructor Description BigArrayList()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T element)
Appends the specified element to the end of this list.void
clear()
static <T> BigArrayList<T>
create()
static <T> BigArrayList<T>
create(int maxSize)
T
get(long index)
Returns the element at the specified position in this list.java.util.Iterator<T>
iterator()
T
set(long theIndex, T theElem)
Set the value of the indexlong
size()
Returns the number of elements in this list.
-
-
-
Field Detail
-
DEFAULT_MAX_SIZE
public static final int DEFAULT_MAX_SIZE
The default max size aList
can have- See Also:
- Constant Field Values
-
-
Method Detail
-
create
public static <T> BigArrayList<T> create()
-
create
public static <T> BigArrayList<T> create(int maxSize)
-
get
public T get(long index)
Returns the element at the specified position in this list.- Parameters:
index
-- Returns:
-
set
public T set(long theIndex, T theElem)
Set the value of the index- Parameters:
theIndex
- the indextheElem
- the element to set at the index- Returns:
- the value
-
add
public boolean add(T element)
Appends the specified element to the end of this list.- Parameters:
element
-- Returns:
-
size
public long size()
Returns the number of elements in this list.- Returns:
-
clear
public void clear()
-
-