Collections Methods Flashcards

1
Q

Collection boolean add(Element elem)

A

Adds elem into the underlying container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Collection void clear()

A

Removes all elements from the container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Collection boolean isEmpty()

A

Returns true if empty, false if not.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Collection Iterator iterator()

A

Returns an Iterator object for iterating over the container.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Collection int size()

A

Returns the number of elements in the container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Collection Object[] toArray()

A

Returns an array that has all elements in the container.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Collection boolean addAll(Collection extends element> coll)

A

Adds all the elements in coll into the underlying container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Collection boolean containsAll(Collection> coll)

A

Checks if all elements given in coll are present in the underlying container.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Collection boolean removeAll(Collection> coll)

A

Removes all elements from the underlying container that are also present in coll.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Collection boolean retainAll(Collection> coll)

A

Retains elements in the underlying container only if they are also present in coll; removes all other elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Iterator boolean hasNext()

A

Returns true if there are more elements to traverse.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Iterator E next()

A

Moves the iterator to the next element and returns that element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Iterator void remove()

A

Removes the last visited element from the underlying container. next() must be called before calling remove, otherwise throws IllegalStateException.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

ListIterator boolean hasPrevious()

A

Checks if the iterator has more elements to traverse in the previous direction.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

ListIterator Element previous()

A

Moves the iterator to the next element and returns that next element in reverse direction()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

ListIterator int nextIndex()

A

Returns the index of the next element in forward direction.

17
Q

ListIterator int previousIndex()

A

Returns the index of the next element in reverse direction.

18
Q

ListIterator void set(Element element)

A

Replaces the last element visited (using next or previous) with element.

19
Q

ListIterator void add(Element element)

A

Adds the element to the list at the current iteration position.

20
Q

Deque void addFirst(Element element)

A

Adds the element to the front of the deque. Raises Exception if full.

21
Q

Deque void addLast(Element element)

A

Adds the element to the end of the deque. Raises Exception if full.

22
Q

Deque Element removeFirst()

A

Removes an element from the front of the Deque and returns it. Raises NoSuchElementException if empty.

23
Q

Deque Element removeLast()

A

Removes and returns the element at the end of the deque. Raises NoSuchElementException if empty.

24
Q

Deque Element getFirst()

A

Returns the first element from the Deque, does not remove. Raises NoSuchElementException if empty.

25
Q

Deque Element getLast()

A

Returns the last element from the Deque, does not remove. Raises NoSuchElementException if empty.

26
Q

Deque boolean offerFirst(element)

A

Returns true if the element was added to the front, false if the deque is full.

27
Q

Deque boolean offerLast(element)

A

Returns true if the element was added to the back, false if the deque is full.

28
Q

Deque Element pollFirst()

A

Removes and returns an element from the front. Returns null if the deque is empty.

29
Q

Deque Element pollLast()

A

Removes and returns an element from the back. Returns null if the deque is empty.

30
Q

Deque Element peekFirst()

A

Returns but does not remove the first element. Returns null if the deque is empty.

31
Q

Deque Element peekLast()

A

Returns but does not remove the last element. Returns null if the deque is empty.