org.rubato.math.yoneda
Class ListMorphismMap

java.lang.Object
  extended by org.rubato.math.yoneda.ListMorphismMap
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<MorphismMap>, MorphismMap, XMLInputOutput<MorphismMap>

public final class ListMorphismMap
extends java.lang.Object
implements MorphismMap

Morphism map containing a list of morphisms (for limit and power types).

Author:
Gérard Milmeister, Stefan Müller, Stefan Göller
See Also:
Serialized Form

Constructor Summary
ListMorphismMap()
          Creates a ListMorphismMap of initial capacity 0.
ListMorphismMap(java.util.Collection<Denotator> denotators)
          Creates a ListMorphismMap.
ListMorphismMap(int n)
          Creates a ListMorphismMap of initial capacity n.
 
Method Summary
 void appendFactor(Denotator d)
          Appends the factor d.
 MorphismMap at(ModuleElement element)
          Returns the list morphism map evaluated at address element.
 MorphismMap changeAddress(Module address)
          Makes an address change.
 MorphismMap changeAddress(ModuleMorphism morphism)
          Makes an address change using a module morphism.
 java.lang.Object clone()
          Returns a copy of this list morphism map.
 int compareTo(ListMorphismMap other)
           
 int compareTo(MorphismMap object)
           
 ListMorphismMap copy()
          Returns a copy of this list morphism map.
 boolean equals(java.lang.Object object)
           
 MorphismMap fromXML(XMLReader reader, org.w3c.dom.Element element)
          Reads XML representation from reader starting with element.
 boolean fullEquals(MorphismMap map, java.util.IdentityHashMap<java.lang.Object,java.lang.Object> s)
           
 java.util.LinkedList<Denotator> getDenotatorDependencies(java.util.LinkedList<Denotator> depList)
           
 java.lang.String getElementTypeName()
          Returns the value of the type attribute for this class.
 Denotator getFactor(int index)
          Returns the factor at position index.
 int getFactorCount()
          Returns the number of factors.
 java.util.ArrayList<Denotator> getFactors()
          Returns the list of factors.
 java.util.LinkedList<Form> getFormDependencies(java.util.LinkedList<Form> dependencyList)
           
 int hashCode()
          Returns a hash code of this list morphism map.
 int indexOf(Denotator d)
          Returns the position index of factor d
 void insertFactor(int index, Denotator d)
          Inserts the factor d at position index.
 boolean isConstant()
           
 boolean isSet()
          Returns true iff the list is actually a set, i.e., without null objects, sorted and without duplicates.
 java.util.Iterator<Denotator> iterator()
          Returns an iterator over the factors.
 void prependFactor(Denotator d)
          Prepends the factor d.
 void removeDuplicates()
          Removes duplicates from the list.
 Denotator removeFactor(int index)
          Removes the factor at index.
 boolean resolveReferences(RubatoDictionary dict, java.util.IdentityHashMap<?,?> history)
          Resolves all references.
 void setFactor(int index, Denotator d)
          Sets the factor at position index to d.
 void sort()
          Sorts the list.
 java.lang.String toString()
           
 void toXML(XMLWriter writer)
          Outputs XML representation to writer.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ListMorphismMap

public ListMorphismMap(int n)
Creates a ListMorphismMap of initial capacity n.


ListMorphismMap

public ListMorphismMap(java.util.Collection<Denotator> denotators)
Creates a ListMorphismMap.


ListMorphismMap

public ListMorphismMap()
Creates a ListMorphismMap of initial capacity 0.

Method Detail

getFactor

public Denotator getFactor(int index)
Returns the factor at position index.


setFactor

public void setFactor(int index,
                      Denotator d)
Sets the factor at position index to d.


insertFactor

public void insertFactor(int index,
                         Denotator d)
Inserts the factor d at position index.


appendFactor

public void appendFactor(Denotator d)
Appends the factor d.


removeFactor

public Denotator removeFactor(int index)
Removes the factor at index.


prependFactor

public void prependFactor(Denotator d)
Prepends the factor d.


getFactorCount

public int getFactorCount()
Returns the number of factors.


getFactors

public java.util.ArrayList<Denotator> getFactors()
Returns the list of factors.


indexOf

public int indexOf(Denotator d)
Returns the position index of factor d


sort

public void sort()
Sorts the list.


isSet

public boolean isSet()
Returns true iff the list is actually a set, i.e., without null objects, sorted and without duplicates.


removeDuplicates

public void removeDuplicates()
Removes duplicates from the list. Requires that the list has been sorted before.


iterator

public java.util.Iterator<Denotator> iterator()
Returns an iterator over the factors.


compareTo

public int compareTo(MorphismMap object)
Specified by:
compareTo in interface java.lang.Comparable<MorphismMap>
Specified by:
compareTo in interface MorphismMap

compareTo

public int compareTo(ListMorphismMap other)

at

public MorphismMap at(ModuleElement element)
               throws MappingException
Returns the list morphism map evaluated at address element.

Specified by:
at in interface MorphismMap
Parameters:
element - evaluate at this element
Returns:
a new morphism map if there has been any change
Throws:
MappingException - if evaluation fails

changeAddress

public MorphismMap changeAddress(Module address)
Description copied from interface: MorphismMap
Makes an address change.

Specified by:
changeAddress in interface MorphismMap
Parameters:
address - the new address of the denotator
Returns:
a copy of this morphism with address newAddress or null if address changed fails

changeAddress

public MorphismMap changeAddress(ModuleMorphism morphism)
Description copied from interface: MorphismMap
Makes an address change using a module morphism.

Specified by:
changeAddress in interface MorphismMap
Parameters:
morphism - the address changing morphism
Returns:
a copy of this morphism with the new address or null if address change fails

isConstant

public boolean isConstant()

toXML

public void toXML(XMLWriter writer)
Description copied from interface: XMLInputOutput
Outputs XML representation to writer.

Specified by:
toXML in interface XMLInputOutput<MorphismMap>

fromXML

public MorphismMap fromXML(XMLReader reader,
                           org.w3c.dom.Element element)
Description copied from interface: XMLInputOutput
Reads XML representation from reader starting with element.

Specified by:
fromXML in interface XMLInputOutput<MorphismMap>
Returns:
an object of type T or null if parsing failed

getElementTypeName

public java.lang.String getElementTypeName()
Description copied from interface: XMLInputOutput
Returns the value of the type attribute for this class.

Specified by:
getElementTypeName in interface XMLInputOutput<MorphismMap>

clone

public java.lang.Object clone()
Returns a copy of this list morphism map.

Specified by:
clone in interface MorphismMap
Overrides:
clone in class java.lang.Object

copy

public ListMorphismMap copy()
Returns a copy of this list morphism map.

Specified by:
copy in interface MorphismMap

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

fullEquals

public boolean fullEquals(MorphismMap map,
                          java.util.IdentityHashMap<java.lang.Object,java.lang.Object> s)
Specified by:
fullEquals in interface MorphismMap

getFormDependencies

public java.util.LinkedList<Form> getFormDependencies(java.util.LinkedList<Form> dependencyList)
Specified by:
getFormDependencies in interface MorphismMap

getDenotatorDependencies

public java.util.LinkedList<Denotator> getDenotatorDependencies(java.util.LinkedList<Denotator> depList)
Specified by:
getDenotatorDependencies in interface MorphismMap

resolveReferences

public boolean resolveReferences(RubatoDictionary dict,
                                 java.util.IdentityHashMap<?,?> history)
Resolves all references.

Specified by:
resolveReferences in interface MorphismMap
Returns:
true iff all references have been resolved.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Returns a hash code of this list morphism map.

Specified by:
hashCode in interface MorphismMap
Overrides:
hashCode in class java.lang.Object
Returns:
the hashcode of this morphism map