The key are use as object reference.
The value is the
object state, it is a set of fields value.
There is two
kind of value:
primitive value, such as number.
the reference to other object, in data record reference are key value of referenced object
Example:
class
Person
{
private String name;
private int age;
}
Composition
A 'personal' contact list
Emma, emma@gmail.com
Jacob, jacob@club.net
Daniel, daniel@orange.fr
Olivia, olivia@msn.com
Matthew, mat@yahoo.com
Contact book class implementation, composition of Person is coded using TreeMap. TreeMap guarantee O(log n) access time.
class ContactBook {
private
Map<String,Person> personByNameMap=new
PTreeMap<String,Person>();
private Map<String,Person>
personByEMailMap=new PTreeMap<String,Person>();
}
Object graph for 'personnal'
contact list
Searching a contact by name or by email is navigating in tree
nodes starting from root object.
Assuming each object are stored
in a data record, data record searching time is O(log dataSize),
object searching time is O(log n) where n is the number of contact.
The search time for a contact is O(log n) * O(log dataSize)