public class DoubleArraySeq
extends java.lang.Object
implements java.lang.Cloneable
(2) A sequence's capacity cannot exceed the maximum integer 2,147,483,647 (Integer.MAX_VALUE). Any attempt to create a larger capacity results in a failure due to an arithmetic overflow., This file contains only blank implementations ("stubs") because this is a Programming Project for my students.
Constructor and Description |
---|
DoubleArraySeq()
Initialize an empty sequence with an initial capacity of 10.
|
DoubleArraySeq(int initialCapacity)
Initialize an empty sequence with a specified initial capacity.
|
Modifier and Type | Method and Description |
---|---|
void |
addAfter(int element)
Add a new element to this sequence, after the current element.
|
void |
addAll(DoubleArraySeq addend)
Place the contents of another sequence at the end of this sequence.
|
void |
addBefore(int element)
Add a new element to this sequence, before the current element.
|
void |
advance()
Move forward, so that the current element is now the next element in
this sequence.
|
static DoubleArraySeq |
catenation(DoubleArraySeq s1,
DoubleArraySeq s2)
Create a new sequence that contains all the elements from one sequence
followed by another.
|
DoubleArraySeq |
clone()
Generate a copy of this sequence.
|
void |
ensureCapacity(int minimumCapacity)
Change the current capacity of this sequence.
|
int |
getCapacity()
Accessor method to get the current capacity of this sequence.
|
double |
getCurrent()
Accessor method to get the current element of this sequence.
|
double |
isCurrent()
Accessor method to determine whether this sequence has a specified
current element that can be retrieved with the
getCurrent method.
|
void |
removeCurrent()
Remove the current element from this sequence.
|
int |
size()
Determine the number of elements in this sequence.
|
void |
start()
Set the current element at the front of this sequence.
|
void |
trimToSize()
Reduce the current capacity of this sequence to its actual size (i.e., the
number of elements it contains).
|
public DoubleArraySeq()
java.lang.OutOfMemoryError
- Indicates insufficient memory for:
new double[10].public DoubleArraySeq(int initialCapacity)
initialCapacity
- the initial capacity of this sequencejava.lang.IllegalArgumentException
- Indicates that initialCapacity is negative.java.lang.OutOfMemoryError
- Indicates insufficient memory for:
new double[initialCapacity].public void addAfter(int element)
element
- the new element that is being addedjava.lang.OutOfMemoryError
- Indicates insufficient memory for increasing the sequence's capacity.public void addBefore(int element)
element
- the new element that is being addedjava.lang.OutOfMemoryError
- Indicates insufficient memory for increasing the sequence's capacity.public void addAll(DoubleArraySeq addend)
addend
- a sequence whose contents will be placed at the end of this sequencejava.lang.NullPointerException
- Indicates that addend is null.java.lang.OutOfMemoryError
- Indicates insufficient memory to increase the size of this sequence.public void advance()
java.lang.IllegalStateException
- Indicates that there is no current element, so
advance may not be called.public DoubleArraySeq clone()
clone
in class java.lang.Object
java.lang.OutOfMemoryError
- Indicates insufficient memory for creating the clone.public static DoubleArraySeq catenation(DoubleArraySeq s1, DoubleArraySeq s2)
s1
- the first of two sequencess2
- the second of two sequencesjava.lang.NullPointerException
- Indicates that one of the arguments is null.java.lang.OutOfMemoryError
- Indicates insufficient memory for the new sequence.public void ensureCapacity(int minimumCapacity)
minimumCapacity
- the new capacity for this sequencejava.lang.OutOfMemoryError
- Indicates insufficient memory for: new int[minimumCapacity].public int getCapacity()
public double getCurrent()
java.lang.IllegalStateException
- Indicates that there is no current element, so
getCurrent may not be called.public double isCurrent()
public void removeCurrent()
java.lang.IllegalStateException
- Indicates that there is no current element, so
removeCurrent may not be called.public int size()
public void start()
public void trimToSize()
java.lang.OutOfMemoryError
- Indicates insufficient memory for altering the capacity.