public class EquivalenceSets<T> extends Object
Title: CASA Agent Infrastructure
Description: Instances of this class maintain named objects under one or more names as "equivalence sets". ie: you can have several names for the same object.
The referenced object do not have to be unique and may be null. Therefore you can use this class to keep just names, which end up being simple synonym strings.
Copyright: Copyright 2003-2014, Knowledge Science Group, University of Calgary. Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. The Knowledge Science Group makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
Company: Knowledge Science Group, University of Calgary
Modifier and Type | Field and Description |
---|---|
private TreeMap<Integer,Vector<String>> |
ids |
private TreeMap<String,Integer> |
names |
private int |
nextID |
private TreeMap<Integer,T> |
objects |
Constructor and Description |
---|
EquivalenceSets()
Default constructor.
|
EquivalenceSets(Collection<String> names)
Initialize this EquivalenceSets object with the the names in names.
|
EquivalenceSets(Map<String,T> map)
Initialize this EquivalenceSets object with the String/Object pairs in map.
|
EquivalenceSets(String[] names)
Initialize this EquivalenceSets object with the the names in names.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equal(String name1,
String name2) |
Object |
get(String name) |
String[] |
getEqClass(String name) |
private int |
getID(String name) |
private int |
getNewID() |
boolean |
hasObject(String name) |
int |
put(String name)
Places a name in the database, associated with a null object.
|
T |
put(String name,
T object)
Places a new name if the database associated with the object.
|
T |
setEqual(String name1,
String name2)
Places the two names in the same equivalence class.
|
public EquivalenceSets()
public EquivalenceSets(Map<String,T> map)
public EquivalenceSets(String[] names)
public EquivalenceSets(Collection<String> names)
private int getNewID()
private int getID(String name)
public int put(String name)
name
- put(String, Object)
public T put(String name, T object)
name
- object
- public T setEqual(String name1, String name2) throws Exception
name1
- name2
- Exception
- If the two names are already associated with an non-null object that aren't equal(), or can't be compared with equal().public Object get(String name)
name
- The name under which to retrieve the object.public String[] getEqClass(String name)
name
- The name from which to retrieve the other equivalent names.public boolean hasObject(String name)
public boolean equal(String name1, String name2)
name1
- name2
- setEqual(String, String)
.