The Octet Molecular Representation Framework v0.8.2

net.sf.octet.collection
Class BasicAtomCollection

java.lang.Object
  extended bynet.sf.octet.collection.BasicAtomCollection
All Implemented Interfaces:
AtomCollection

public class BasicAtomCollection
extends java.lang.Object
implements AtomCollection

A default implementation of the AtomCollection interface backed by an ArraySequence.

Author:
Richard Apodaca

Constructor Summary
BasicAtomCollection()
          Constructs an empty BasicAtomCollection.
BasicAtomCollection(Atom[] atoms)
          Constructs a BasicAtomCollection from the elements contained in atoms.
BasicAtomCollection(java.util.Collection atoms)
          Constructs a BasicAtomCollection from the elements contained in atoms.
 
Method Summary
 boolean containsAtom(Atom atom)
          Returns true if the specified Atom is contained in this collection, and false otherwise.
 int countAtoms()
          Returns the number of Atoms contained in this atom collection.
 Atom getAtom(int index)
          Returns the Atom located at the specified zero-based index.
 int getAtomIndex(Atom atom)
          Returns the zero-based index of the specified Atom.
 AtomIterator iterateAtoms()
          Returns an iterator over all Atoms in this collection.
 Atom[] toAtomArray()
          Returns a copy of the Atoms contained in this collection as an array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicAtomCollection

public BasicAtomCollection()
Constructs an empty BasicAtomCollection.


BasicAtomCollection

public BasicAtomCollection(java.util.Collection atoms)
Constructs a BasicAtomCollection from the elements contained in atoms.

Parameters:
atoms - the collection from which to get Atoms
Throws:
java.lang.IllegalArgumentException - if atoms contains Objects that do not implement Atom
java.lang.NullPointerException - if atoms contains null

BasicAtomCollection

public BasicAtomCollection(Atom[] atoms)
Constructs a BasicAtomCollection from the elements contained in atoms.

Parameters:
atoms - the array from which to get Atoms
Throws:
java.lang.IllegalArgumentException - if atoms contains Objects that do not implement Atom
java.lang.NullPointerException - if atoms contains null
Method Detail

containsAtom

public boolean containsAtom(Atom atom)
Description copied from interface: AtomCollection
Returns true if the specified Atom is contained in this collection, and false otherwise.

Specified by:
containsAtom in interface AtomCollection
Parameters:
atom - the Atom
Returns:
true if contained, false otherwise

countAtoms

public int countAtoms()
Description copied from interface: AtomCollection
Returns the number of Atoms contained in this atom collection.

Specified by:
countAtoms in interface AtomCollection
Returns:
the number of atoms in this collection

getAtomIndex

public int getAtomIndex(Atom atom)
Description copied from interface: AtomCollection
Returns the zero-based index of the specified Atom.

Specified by:
getAtomIndex in interface AtomCollection
Parameters:
atom - the atom
Returns:
the index of the atom, or -1 if this collection does not contain atom

getAtom

public Atom getAtom(int index)
Description copied from interface: AtomCollection
Returns the Atom located at the specified zero-based index.

Specified by:
getAtom in interface AtomCollection
Parameters:
index - the index
Returns:
the Atom at index, or null if the index is invalid

iterateAtoms

public AtomIterator iterateAtoms()
Description copied from interface: AtomCollection
Returns an iterator over all Atoms in this collection.

Specified by:
iterateAtoms in interface AtomCollection
Returns:
an iterator over all Atoms in this collection

toAtomArray

public Atom[] toAtomArray()
Description copied from interface: AtomCollection
Returns a copy of the Atoms contained in this collection as an array. The resulting array may be modified without changing the state of this collection.

Specified by:
toAtomArray in interface AtomCollection
Returns:
a copy of the Atom array for this collection

The Octet Molecular Representation Framework v0.8.2