jdsl.core.ref
Class AbstractPositionalContainer
java.lang.Object
jdsl.core.ref.AbstractPositionalContainer
- All Implemented Interfaces:
- Container, InspectableContainer, InspectablePositionalContainer, PositionalContainer
- Direct Known Subclasses:
- AbstractGraph, ArraySequence, NodeBinaryTree, NodeSequence, NodeTree
- public abstract class AbstractPositionalContainer
- extends Object
- implements PositionalContainer
An abstract positional container that others may extend if they do not
wish to deal with some of the more mundane aspects of
positional containers and/or if they wish to avoid implementing themselves
some of the methods of container that aren't terribly pertinent to
a PositionalContainer. Feel free to override any of these methods in
subclasses, but be certain that they work according
to the API in jdsl.core.api.
Also handles isEmpty() from InspectableContainer.
- Version:
- JDSL 2.1.1
- Author:
- Andrew Schwerin (schwerin), Benoit Hudson (bh), Ryan Shaun Baker (rsb)
- See Also:
PositionalContainer
Method Summary |
boolean |
isEmpty()
Checks if this container is empty. |
void |
swapElements(Position a,
Position b)
Works on top of PositionalContainer method
replaceElement(Position, Object) and InspectableContainer method
contains(). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractPositionalContainer
public AbstractPositionalContainer()
swapElements
public void swapElements(Position a,
Position b)
throws InvalidAccessorException
- Works on top of PositionalContainer method
replaceElement(Position, Object) and InspectableContainer method
contains().
- Specified by:
swapElements
in interface PositionalContainer
- Parameters:
a
- First Position to swapb
- Second Position to swap
- Throws:
InvalidAccessorException
- if either of a
and b
is null or does not belong to this positional
container
isEmpty
public boolean isEmpty()
- Checks if this container is empty.
Has the same time complexity as size(). If size() is O(n) and you can
write isEmpty() in O(1) time, then override this method.
- Specified by:
isEmpty
in interface InspectableContainer
- Returns:
true
if and only if the container is empty (holds
no elements)- See Also:
InspectableBinaryTree