kodkod.util.ints
Class AbstractIndexedEntry<V>

java.lang.Object
  extended by kodkod.util.ints.AbstractIndexedEntry<V>
All Implemented Interfaces:
IndexedEntry<V>

public abstract class AbstractIndexedEntry<V>
extends java.lang.Object
implements IndexedEntry<V>

A skeletal implementation of the IndexedEntry interface.

Author:
Emina Torlak
specfield:
index: int
value: V

Method Summary
 boolean equals(java.lang.Object o)
          Compares the specified object with this entry for equality.
 int hashCode()
          Returns the hash code value for this indexed entry.
 int index()
          Returns the index of this entry.
 java.lang.String toString()
           
 V value()
          Returns the value stored in this entry.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

index

public int index()
Description copied from interface: IndexedEntry
Returns the index of this entry.

Specified by:
index in interface IndexedEntry<V>
Returns:
this.index
See Also:
IndexedEntry.index()

value

public V value()
Description copied from interface: IndexedEntry
Returns the value stored in this entry.

Specified by:
value in interface IndexedEntry<V>
Returns:
this.value
See Also:
IndexedEntry.value()

equals

public boolean equals(java.lang.Object o)
Compares the specified object with this entry for equality. Returns true if the given object is also an indexed entry and the two entries have the same indeces and values. More formally, two entries e1 and e2 are equal if e1.index = e2.index && e1.value = e2.value. This ensures that the equals method works properly across different implementations of the IndexedEntry interface.

Specified by:
equals in interface IndexedEntry<V>
Overrides:
equals in class java.lang.Object
Returns:
o in IndexedEntry && o.index = this.index && o.value = this.value

hashCode

public int hashCode()
Returns the hash code value for this indexed entry. The hash code of an indexed entry e is defined to be: e.index ^ (e.value=null ? 0 : e.value.hashCode()). This ensures that e1.equals(e2) implies that e1.hashCode()==e2.hashCode() for any two IndexedEntries e1 and e2, as required by the general contract of Object.hashCode.

Specified by:
hashCode in interface IndexedEntry<V>
Overrides:
hashCode in class java.lang.Object

toString

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