The Octet Molecular Representation Framework v0.8.2

net.sf.octet.collection
Class BasicNucleusCollection

java.lang.Object
  extended bynet.sf.octet.collection.BasicNucleusCollection
All Implemented Interfaces:
NucleusCollection

public class BasicNucleusCollection
extends java.lang.Object
implements NucleusCollection

A default implementation of the NucleusCollection interface backed by a ArraySequence.

Author:
Richard Apodaca

Constructor Summary
BasicNucleusCollection()
          Constructs an empty BasicNucleusCollection.
BasicNucleusCollection(java.util.Collection nuclei)
          Constructs a BasicNucleusCollection from the elements contained in nuclei.
BasicNucleusCollection(Nucleus[] nuclei)
          Constructs a BasicNucleusCollection from the elements contained in nuclei.
 
Method Summary
 boolean containsNucleus(Nucleus nucleus)
          Returns true if the specified Nucleus is contained in this collection, and false otherwise.
 int countNuclei()
          Returns the number of Nuclei contained in this collection.
 Nucleus getNucleus(int index)
          Returns the isotope located at the specified zero-based index.
 int getNucleusIndex(Nucleus nucleus)
          Returns the zero-based index of the specified Nucleus.
 NucleusIterator iterateNuclei()
          Returns an iterator over all Nuclei in this collection.
 Nucleus[] toNucleusArray()
          Returns a copy of the Nuclei 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

BasicNucleusCollection

public BasicNucleusCollection()
Constructs an empty BasicNucleusCollection.


BasicNucleusCollection

public BasicNucleusCollection(java.util.Collection nuclei)
Constructs a BasicNucleusCollection from the elements contained in nuclei.

Parameters:
nuclei - the collection from which to get Nuclei
Throws:
java.lang.IllegalArgumentException - if nuclei contains Objects that do not implement Nucleus
java.lang.NullPointerException - if nuclei contains null

BasicNucleusCollection

public BasicNucleusCollection(Nucleus[] nuclei)
Constructs a BasicNucleusCollection from the elements contained in nuclei.

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

containsNucleus

public boolean containsNucleus(Nucleus nucleus)
Description copied from interface: NucleusCollection
Returns true if the specified Nucleus is contained in this collection, and false otherwise.

Specified by:
containsNucleus in interface NucleusCollection
Parameters:
nucleus - the Nucleus
Returns:
true if contained, false otherwise

countNuclei

public int countNuclei()
Description copied from interface: NucleusCollection
Returns the number of Nuclei contained in this collection.

Specified by:
countNuclei in interface NucleusCollection
Returns:
the number of Nuclei in this collection

getNucleusIndex

public int getNucleusIndex(Nucleus nucleus)
Description copied from interface: NucleusCollection
Returns the zero-based index of the specified Nucleus.

Specified by:
getNucleusIndex in interface NucleusCollection
Parameters:
nucleus - the nucleus
Returns:
the index of the nucleus, or -1 if this collection does not contain nucleus

getNucleus

public Nucleus getNucleus(int index)
Description copied from interface: NucleusCollection
Returns the isotope located at the specified zero-based index.

Specified by:
getNucleus in interface NucleusCollection
Parameters:
index - the index
Returns:
the Nucleus at index, or null if the index is invalid

iterateNuclei

public NucleusIterator iterateNuclei()
Description copied from interface: NucleusCollection
Returns an iterator over all Nuclei in this collection.

Specified by:
iterateNuclei in interface NucleusCollection
Returns:
an iterator over all Nuclei in this collection

toNucleusArray

public Nucleus[] toNucleusArray()
Description copied from interface: NucleusCollection
Returns a copy of the Nuclei contained in this collection as an array. The resulting array may be modified without changing the state of this collection.

Specified by:
toNucleusArray in interface NucleusCollection
Returns:
a copy of the Nucleus array for this collection

The Octet Molecular Representation Framework v0.8.2