public class IntDeque extends Object
Missing tests and missing methods: (push|peek|pop)(Back|Front).
Modifier and Type | Field and Description |
---|---|
protected int |
size |
Constructor and Description |
---|
IntDeque()
Constructs an empty Bag with an initial capacity of 64.
|
IntDeque(int capacity)
Constructs an empty Bag with the specified initial capacity.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int e)
Adds the specified element to the end of this bag.
|
void |
clear()
Removes all of the elements from this bag.
|
boolean |
contains(int e)
Check if bag contains this element.
|
void |
ensureCapacity(int index)
Check if an item, if added at the given item will fit into the bag.
|
boolean |
equals(Object o) |
int |
get(int index)
Returns the element at the specified position in Bag.
|
int |
getCapacity()
Returns the number of elements the bag can hold without growing.
|
int |
hashCode() |
boolean |
isEmpty()
Returns true if this bag contains no elements.
|
int |
popFirst() |
int |
popLast() |
void |
set(int index,
int e)
Set element at specified index in the bag.
|
void |
setSize(int size)
Set the size.
|
int |
size()
Returns the number of elements in this bag.
|
String |
toString() |
public IntDeque()
public IntDeque(int capacity)
capacity
- the initial capacity of Bagpublic boolean contains(int e)
e
- element to checktrue
if the bag contains this elementpublic int get(int index) throws ArrayIndexOutOfBoundsException
index
- index of the element to returnArrayIndexOutOfBoundsException
public int size()
public int getCapacity()
public boolean isEmpty()
true
if this bag contains no elementspublic void add(int e)
If required, it also increases the capacity of the bag.
e
- element to be added to this listpublic void set(int index, int e)
index
- position of elemente
- the elementpublic void ensureCapacity(int index)
If not, the bag capacity will be increased to hold an item at the index.
index
- index to checkpublic void clear()
The bag will be empty after this call returns.
public void setSize(int size)
This will not resize the bag, nor will it clean up contents beyond the given size. Use with caution.
size
- the size to setpublic int popLast()
public int popFirst()
Copyright © 2019. All rights reserved.