Пример #1
0
        protected override void Expand()
        {
            // Build a selector of table values which were non-empty
            int[] indices = new int[_assignedIndices.Length];

            byte[] metadata = this.Metadata;
            int    count    = 0;

            for (int i = 0; i < indices.Length; ++i)
            {
                if (metadata[i] != 0)
                {
                    indices[count++] = i;
                }
            }

            // Save the old keys, ranks, and row indices in arrays
            XArray[] keyArrays = new XArray[_keys.Length];
            for (int i = 0; i < _keys.Length; ++i)
            {
                keyArrays[i] = XArray.All(_keys[i].Values).Reselect(ArraySelector.Map(indices, count));
            }

            XArray indicesArray = XArray.All(_assignedIndices).Reselect(ArraySelector.Map(indices, count));

            // Expand the table
            Reset(HashCore.ResizeToSize(_assignedIndices.Length));

            // Add items to the enlarged table
            FindOrAdd(keyArrays, indicesArray);
        }
Пример #2
0
        public GroupByDictionary(ColumnDetails[] keyColumns, int initialCapacity = -1)
        {
            _keyColumns = keyColumns;

            // Create a strongly typed column for each key
            _keys = new IDictionaryColumn[keyColumns.Length];
            for (int i = 0; i < keyColumns.Length; ++i)
            {
                _keys[i] = (IDictionaryColumn)Allocator.ConstructGenericOf(typeof(DictionaryColumn <>), keyColumns[i].Type);
            }

            // Allocate the arrays for the keys and values themselves
            Reset(HashCore.SizeForCapacity(initialCapacity));
        }
Пример #3
0
        protected override void Expand()
        {
            // Save the current Keys/Values/Metadata
            T[]    oldKeys     = _keys;
            U[]    oldValues   = _values;
            byte[] oldMetaData = this.Metadata;

            // Expand the table
            Reset(HashCore.ResizeToSize(_keys.Length));

            // Add items to the enlarged table
            for (int i = 0; i < oldMetaData.Length; ++i)
            {
                if (oldMetaData[i] > 0)
                {
                    Add(oldKeys[i], oldValues[i]);
                }
            }
        }
Пример #4
0
        public ChooseDictionary(ChooseDirection direction, ColumnDetails rankColumn, ColumnDetails[] keyColumns, int initialCapacity = -1)
        {
            _chooseDirection = direction;
            _keyColumns      = keyColumns;
            _rankColumn      = rankColumn;

            // Create a strongly typed column for each key
            _keys = new IDictionaryColumn[keyColumns.Length];
            for (int i = 0; i < keyColumns.Length; ++i)
            {
                _keys[i] = (IDictionaryColumn)Allocator.ConstructGenericOf(typeof(DictionaryColumn <>), keyColumns[i].Type);
            }

            // Create a strongly typed column to hold rank values
            _ranks          = (IDictionaryColumn)Allocator.ConstructGenericOf(typeof(DictionaryColumn <>), rankColumn.Type);
            _bestRowIndices = (IDictionaryColumn)Allocator.ConstructGenericOf(typeof(DictionaryColumn <>), typeof(int));

            // Allocate the arrays for the keys and values themselves
            Reset(HashCore.SizeForCapacity(initialCapacity));
        }
Пример #5
0
 public Dictionary5(IEqualityComparer <T> comparer, int initialCapacity = -1)
 {
     _comparer = comparer;
     Reset(HashCore.SizeForCapacity(initialCapacity));
 }