public class DynamicBooleanArray extends ModifiedVersionBase implements java.lang.Cloneable
ArrayList
)Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_INITIAL_CAPACITY |
Constructor and Description |
---|
DynamicBooleanArray()
Dynamic array of integers with default capacity of 10
|
DynamicBooleanArray(boolean... vals) |
DynamicBooleanArray(DynamicBooleanArray array) |
DynamicBooleanArray(int initialCapacity)
Dynamic array of integers with provided initial capacity
|
Modifier and Type | Method and Description |
---|---|
void |
add(boolean e) |
void |
addAll(boolean[] e) |
void |
addAll(DynamicBooleanArray array) |
void |
chop(int start,
int size)
Performs an in-place slice, modifying this array directly
|
void |
clear() |
DynamicBooleanArray |
clone()
Creates a shallow copy
|
void |
ensureCapacity(int cap) |
boolean |
equals(DynamicBooleanArray array)
Returns
true if this DynamicBooleanArray is equals to
another one. |
boolean |
get(int idx) |
boolean[] |
getArray()
Provides direct access to the underlying array.
|
boolean |
remove(int idx) |
void |
remove(int idx,
int count)
Remove a specified number of elements starting at the
provided index.
|
void |
resize(int size)
Resizes the array.
|
void |
set(int idx,
boolean e)
Sets the value at index
idx to the provided e . |
int |
size() |
DynamicBooleanArray |
slice(int start,
int size)
Returns a copy of a portion of the array
|
boolean[] |
toArray()
Copies the contents of this DynamicBooleanArray into an array.
|
void |
trimToSize() |
getVersion, notifyModified
public static final int DEFAULT_INITIAL_CAPACITY
public DynamicBooleanArray()
public DynamicBooleanArray(int initialCapacity)
initialCapacity
- initial capacity. If <=
0, uses
the default capacitypublic DynamicBooleanArray(boolean... vals)
public DynamicBooleanArray(DynamicBooleanArray array)
public void ensureCapacity(int cap)
public int size()
public void add(boolean e)
public void addAll(boolean[] e)
public void addAll(DynamicBooleanArray array)
public void clear()
public boolean remove(int idx)
public void remove(int idx, int count)
idx
- starting index to removecount
- number of elements to removepublic void trimToSize()
public void resize(int size)
size
- new sizepublic DynamicBooleanArray slice(int start, int size)
start
- starting index to copysize
- number of elementspublic void chop(int start, int size)
start
- starting index to keepsize
- number of elementspublic boolean get(int idx)
public void set(int idx, boolean e)
idx
to the provided e
.
If idx==size()
, then the element is appended to the array.idx
- index at which to modify the valuee
- new valuepublic boolean[] getArray()
ModifiedVersionBase.notifyModified()
is called. The underying array is automatically trimmed to the correct size
before being returned.public boolean[] toArray()
public DynamicBooleanArray clone()
clone
in class java.lang.Object
public boolean equals(DynamicBooleanArray array)
true
if this DynamicBooleanArray is equals to
another one.array
- array to compare with