Package org.mozilla.javascript
Class EmbeddedSlotMap
- java.lang.Object
-
- org.mozilla.javascript.EmbeddedSlotMap
-
- All Implemented Interfaces:
java.lang.Iterable<ScriptableObject.Slot>,SlotMap
public class EmbeddedSlotMap extends java.lang.Object implements SlotMap
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classEmbeddedSlotMap.Iter
-
Field Summary
Fields Modifier and Type Field Description private intcountprivate ScriptableObject.SlotfirstAddedprivate static intINITIAL_SLOT_SIZEprivate ScriptableObject.SlotlastAddedprivate ScriptableObject.Slot[]slots
-
Constructor Summary
Constructors Constructor Description EmbeddedSlotMap()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidaddKnownAbsentSlot(ScriptableObject.Slot[] addSlots, ScriptableObject.Slot slot)Add slot with keys that are known to absent from the table.voidaddSlot(ScriptableObject.Slot newSlot)Insert a new slot to the map.private static voidcopyTable(ScriptableObject.Slot[] oldSlots, ScriptableObject.Slot[] newSlots)private ScriptableObject.SlotcreateSlot(java.lang.Object key, int indexOrHash, ScriptableObject.SlotAccess accessType, ScriptableObject.Slot existingSlot)ScriptableObject.Slotget(java.lang.Object key, int index, ScriptableObject.SlotAccess accessType)Locate the slot with given name or index.private static intgetSlotIndex(int tableSize, int indexOrHash)private voidinsertNewSlot(ScriptableObject.Slot newSlot)booleanisEmpty()Return whether the map is empty.java.util.Iterator<ScriptableObject.Slot>iterator()ScriptableObject.Slotquery(java.lang.Object key, int index)Locate the slot with the given name or index.voidremove(java.lang.Object key, int index)Remove the slot at either "key" or "index".intsize()Return the size of the map.
-
-
-
Field Detail
-
slots
private ScriptableObject.Slot[] slots
-
firstAdded
private ScriptableObject.Slot firstAdded
-
lastAdded
private ScriptableObject.Slot lastAdded
-
count
private int count
-
INITIAL_SLOT_SIZE
private static final int INITIAL_SLOT_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
size
public int size()
Description copied from interface:SlotMapReturn the size of the map.
-
isEmpty
public boolean isEmpty()
Description copied from interface:SlotMapReturn whether the map is empty.
-
iterator
public java.util.Iterator<ScriptableObject.Slot> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<ScriptableObject.Slot>
-
query
public ScriptableObject.Slot query(java.lang.Object key, int index)
Locate the slot with the given name or index.
-
get
public ScriptableObject.Slot get(java.lang.Object key, int index, ScriptableObject.SlotAccess accessType)
Locate the slot with given name or index. Depending on the accessType parameter and the current slot status, a new slot may be allocated.
-
createSlot
private ScriptableObject.Slot createSlot(java.lang.Object key, int indexOrHash, ScriptableObject.SlotAccess accessType, ScriptableObject.Slot existingSlot)
-
addSlot
public void addSlot(ScriptableObject.Slot newSlot)
Description copied from interface:SlotMapInsert a new slot to the map. Both "name" and "indexOrHash" must be populated. Note that ScriptableObject generally adds slots via the "get" method.
-
insertNewSlot
private void insertNewSlot(ScriptableObject.Slot newSlot)
-
remove
public void remove(java.lang.Object key, int index)Description copied from interface:SlotMapRemove the slot at either "key" or "index".
-
copyTable
private static void copyTable(ScriptableObject.Slot[] oldSlots, ScriptableObject.Slot[] newSlots)
-
addKnownAbsentSlot
private static void addKnownAbsentSlot(ScriptableObject.Slot[] addSlots, ScriptableObject.Slot slot)
Add slot with keys that are known to absent from the table. This is an optimization to use when inserting into empty table, after table growth or during deserialization.
-
getSlotIndex
private static int getSlotIndex(int tableSize, int indexOrHash)
-
-