Exemple #1
0
        public bool TryCreateObject(ObjectType objectType, out IPersistable persistObj)
        {
            switch (objectType)
            {
            case ObjectType.StorageItem:
                persistObj = new StorageItem();
                break;

            case ObjectType.ScalableDictionaryNode:
                persistObj = new ScalableDictionaryNode();
                break;

            case ObjectType.ScalableDictionaryValues:
                persistObj = new ScalableDictionaryValues();
                break;

            case ObjectType.StorableArray:
                persistObj = new StorableArray();
                break;

            case ObjectType.ScalableHybridListEntry:
                persistObj = new ScalableHybridListEntry();
                break;

            default:
                persistObj = null;
                return(false);
            }
            return(true);
        }
 private void CheckNonFreeEntry(ScalableHybridListEntry entry, int index)
 {
     if (entry.Previous == -1 && index != m_first)
     {
         Global.Tracer.Assert(false, "Cannot use index: {0}. It points to a free item", index);
     }
 }
        private ScalableHybridListEntry GetAndCheckEntry(int index)
        {
            ScalableHybridListEntry scalableHybridListEntry = m_entries[index];

            CheckNonFreeEntry(scalableHybridListEntry, index);
            return(scalableHybridListEntry);
        }
Exemple #4
0
 private static List <Declaration> BuildDeclarations()
 {
     return(new List <Declaration>(8)
     {
         BaseReference.GetDeclaration(),
         ScalableList <StorageItem> .GetDeclaration(),
         ScalableDictionary <int, StorageItem> .GetDeclaration(),
         ScalableDictionaryNode.GetDeclaration(),
         ScalableDictionaryValues.GetDeclaration(),
         StorageItem.GetDeclaration(),
         StorableArray.GetDeclaration(),
         ScalableHybridListEntry.GetDeclaration()
     });
 }
        internal int Add(T item)
        {
            int num = -1;

            if (m_firstFree != -1)
            {
                num = m_firstFree;
                ScalableHybridListEntry item2;
                using (m_entries.GetAndPin(m_firstFree, out item2))
                {
                    m_firstFree = item2.Next;
                    SetupLastNode(item2, item);
                }
            }
            else
            {
                num = m_entries.Count;
                ScalableHybridListEntry scalableHybridListEntry = new ScalableHybridListEntry();
                SetupLastNode(scalableHybridListEntry, item);
                m_entries.Add(scalableHybridListEntry);
            }
            if (m_count == 0)
            {
                m_first = num;
            }
            else
            {
                ScalableHybridListEntry item3;
                using (m_entries.GetAndPin(m_last, out item3))
                {
                    item3.Next = num;
                }
            }
            m_last = num;
            m_count++;
            return(num);
        }
 private void SetupLastNode(ScalableHybridListEntry entry, T item)
 {
     entry.Item     = item;
     entry.Next     = -1;
     entry.Previous = m_last;
 }