Exemplo n.º 1
0
        /// <summary>
        /// Tries to resize the node value count
        /// </summary>
        /// <typeparam name="TItem">Type of the item</typeparam>
        /// <typeparam name="TKey">Type of the key</typeparam>
        /// <param name="self"></param>
        /// <param name="node"></param>
        /// <param name="toSum">quantity to sum</param>
        private static void TryResizeValues <TItem, TKey>(this UniqueKeyQuery <TItem, TKey> self, ReferenceNode <TItem, TKey> node, int toSum)
        {
            if (node.Values.Length >= self.State.MaxLengthPerNode)
            {
                node = self.LastRefNode(self.Root);
            }

            node.Values = node.Values
                          .Resize(node.Values.Length + toSum);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds to the value count
        /// </summary>
        /// <typeparam name="TItem">Type of the item</typeparam>
        /// <typeparam name="TKey">Type of the key</typeparam>
        /// <param name="self"></param>
        /// <param name="sumQtd"></param>
        public static void AugmentValueCount <TItem, TKey>(this UniqueKeyQuery <TItem, TKey> self, int sumQtd)
        {
            var lastRefNode =
                self.LastRefNode(self.Root);

            //if needs to change to the next ref node
            if (lastRefNode.Length >= self.State.MaxLengthPerNode)
            {
                self.TryResizeReferencesByOne(lastRefNode);
            }
            else
            {
                TryResizeValues(self, lastRefNode, sumQtd);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Diminishes the value count from a unique key query
        /// </summary>
        /// <typeparam name="TItem">Type of the item</typeparam>
        /// <typeparam name="TKey">Type of the key</typeparam>
        /// <param name="self">The query</param>
        /// <param name="qtdToSubtract">Quantity to substract</param>
        public static void AbridgeValueCount <TItem, TKey>(this UniqueKeyQuery <TItem, TKey> self, int qtdToSubtract)
        {
            var lastRefNode =
                self.LastRefNode(self.Root);

            if (lastRefNode.Length < 2)
            {
                TryEraseNode(lastRefNode.Parent);
            }
            else
            {
                lastRefNode.Values = lastRefNode
                                     .Values.Resize(lastRefNode.Length - 1);
            }
        }