| 
 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectedu.vub.at.objects.natives.FieldMap
Instances of this class implement a so-called 'map' for an AmbientTalk object's fields. The terminology stems from the language Self. A 'map' maps variable names to an integer index. This index can be used to index an object's state vector to retrieve the value of a slot. The advantage of maps lies in their space effiency: clones can share maps, thereby enabling the sharing of variable names (which are immutable). We implement a custom map from symbols to Java ints ourselves, because the java.util.HashMap requires explicit boxing and unboxing of integers as java.lang.Integers, which is wasteful.
| Field Summary | |
| private static int | _DEFAULT_SIZE_ | 
| private  int | free_ | 
| private  FieldMap | origin_ | 
| private  ATSymbol[] | varNames_ | 
| Constructor Summary | |
|   | FieldMap() | 
| private  | FieldMap(ATSymbol[] copiedNames,
         int copiedFree,
         FieldMap origin) | 
| Method Summary | |
| (package private)  FieldMap | copy()Creates a shallow copy of the field map. | 
| private  int | findName(ATSymbol nam)Searches for the name of a field in the varNames_ array. | 
|  int | get(ATSymbol nam)Retrieve the index of a field given its name. | 
|  boolean | isDerivedFrom(FieldMap aFieldMap)Checks whether both FieldMaps are equal or whether the passed object is a FieldMap from which this one (indirectly) originates. | 
|  ATSymbol[] | listFields()Returns all field names. | 
|  boolean | put(ATSymbol nam)Add a new field to the field map. | 
| private  void | reAlloc()Doubles the size of the map to make room for extra fields. | 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
private static final int _DEFAULT_SIZE_
private ATSymbol[] varNames_
private int free_
private FieldMap origin_
| Constructor Detail | 
public FieldMap()
private FieldMap(ATSymbol[] copiedNames,
                 int copiedFree,
                 FieldMap origin)
| Method Detail | 
public boolean put(ATSymbol nam)
public int get(ATSymbol nam)
nam - the name of the field
public ATSymbol[] listFields()
FieldMap copy()
public boolean isDerivedFrom(FieldMap aFieldMap)
private void reAlloc()
private int findName(ATSymbol nam)
| 
 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||