/// <summary> /// Gets the value associated with the specified key, /// without bringing to Nil the non-existant values. /// </summary> /// <param name="key">The key.</param> public DynValue RawGet(DynValue key) { if (!_isAlive) { throw new InvalidOperationException(string.Format("Attempting to RawGet on dead Table")); } if (key.Type == DataType.String) { return(RawGet(key.String)); } if (key.Type == DataType.Number) { int idx = GetIntegralKey(key.Number); if (idx > 0) { return(RawGet(idx)); } } if (m_ValueMap == null) { return(DynValue.Invalid); } return(RawGetValue(m_ValueMap.Find(key))); }
private void PerformTableSet <T>(LinkedListIndex <T, TablePair> listIndex, T key, DynValue keyDynValue, DynValue value, bool isNumber, int appendKey) { if (!_isAlive) { throw new InvalidOperationException(string.Format("Attempting to PerformTableSet on dead Table")); } TablePair prev = listIndex.Set(key, new TablePair(keyDynValue, value)); // If this is an insert, we can invalidate all iterators and collect dead keys if (m_ContainsNilEntries && value.IsNotNil() && (prev.Value.IsNil())) { CollectDeadKeys(); } // If this value is nil (and we didn't collect), set that there are nil entries, and invalidate array len cache else if (value.IsNil()) { m_ContainsNilEntries = true; if (isNumber) { m_CachedLength = -1; } } else if (isNumber) { // If this is an array insert, we might have to invalidate the array length if (prev.Value.IsNilOrNan()) { // If this is an array append, let's check the next element before blindly invalidating if (appendKey >= 0) { if (m_ArrayMap == null) { m_CachedLength += 1; } else { LinkedListNode <TablePair> next = m_ArrayMap.Find(appendKey + 1); if (next == null || next.Value.Value.IsNil()) { m_CachedLength += 1; } else { m_CachedLength = -1; } } } else { m_CachedLength = -1; } } } }
/// <summary> /// Gets the value associated with the specified key, /// without bringing to Nil the non-existant values. /// </summary> /// <param name="key">The key.</param> public DynValue RawGet(string key) { if (!_isAlive) { throw new InvalidOperationException(string.Format("Attempting to RawGet on dead Table")); } if (m_StringMap == null) { return(DynValue.Invalid); } return(RawGetValue(m_StringMap.Find(key))); }
/// <summary> /// Gets the value associated with the specified key. /// </summary> /// <param name="key">The key.</param> /// <returns></returns> public DynValue Get(DynValue key) { if (key.Type == DataType.Number) { int idx = GetIntegralKey(key.Number); if (idx > 0) { return(GetValueOrNil(m_ArrayMap.Find(idx))); } } else if (key.Type == DataType.String) { return(GetValueOrNil(m_StringMap.Find(key.String))); } return(GetValueOrNil(m_ValueMap.Find(key))); }
/// <summary> /// Gets the value associated with the specified key, /// without bringing to Nil the non-existant values. /// </summary> /// <param name="key">The key.</param> public DynValue RawGet(DynValue key) { if (key.Type == DataType.String) { return(RawGet(key.String)); } if (key.Type == DataType.Number) { int idx = GetIntegralKey(key.Number); if (idx > 0) { return(RawGet(idx)); } } return(RawGetValue(m_ValueMap.Find(key))); }
/// <summary> /// Gets the value associated with the specified key, /// without bringing to Nil the non-existant values. /// </summary> /// <param name="key">The key.</param> public DynValue RawGet(DynValue key) { if (key.Type == DataType.String) { return(RawGet(key.String)); } if (key.Type == DataType.Number) { int idx = GetIntegralKey(key.Number); if (idx >= (OwnerScript.Options.ZeroIndexTables ? 0 : 1)) { return(RawGet(idx)); } } return(RawGetValue(m_ValueMap.Find(key))); }
/// <summary> /// Gets the value associated with the specified key, /// without bringing to Nil the non-existant values. /// </summary> /// <param name="key">The key.</param> public DynValue RawGet(string key) { return(RawGetValue(m_StringMap.Find(key))); }
/// <summary> /// Gets the value associated with the specified key, /// without bringing to Nil the non-existant values. /// </summary> /// <param name="key">The key.</param> public DynValue RawGet(int key) { return(RawGetValue(m_ArrayMap.Find(key))); }