Esempio n. 1
0
        public bool MoveNext()
        {
            var         node        = _current_Node;
            var         key         = _current_Key;
            long        dataAddress = 0;
            Data <TKey> data;

            if (!_Current_Has_Value)
            {
                dataAddress = node.Get_Data_Address(key);
                Current     = data = _reader.Read_Data(dataAddress);
                return(_Current_Has_Value = true);
            }

            int indexOf = Array.BinarySearch(node.Keys, 0, node.Key_Num, key) + 1;

            if (indexOf < node.Key_Num)
            {
                key = node.Keys[indexOf];
            }
            else
            {
                while (_current_Key.CompareTo(key) >= 0)
                {
                    if (node.Parent == null)
                    {
                        Current = null;
                        return(_Current_Has_Value = false);
                    }

                    node = node.Parent;

                    indexOf = Array.BinarySearch(node.Keys, 0, node.Key_Num, key);
                    if (indexOf < 0)
                    {
                        indexOf = ~indexOf;
                    }

                    if (indexOf == node.Key_Num)
                    {
                        indexOf--;
                    }
                    key = node.Keys[indexOf];
                }
            }

            node          = _reader.Find_Leaf_Node(key, node);
            _current_Node = node;
            _current_Key  = key;

            dataAddress = node.Get_Data_Address(key);
            Current     = data = _reader.Read_Data(dataAddress);
            return(_Current_Has_Value = true);
        }
        public bool MoveNext()
        {
            var node = _current_Node;
            var key  = _current_Key;

            if (!_Current_Has_Value)
            {
                Current            = _current_Key;
                _Current_Has_Value = true;
                return(true);
            }

            int indexOf = Array.BinarySearch(node.Keys, 0, node.Key_Num, key) + 1;

            if (indexOf < node.Key_Num)
            {
                key = node.Keys[indexOf];
            }
            else
            {
                while (_current_Key.CompareTo(key) >= 0)
                {
                    if (node.Parent == null)
                    {
                        return(false);
                    }

                    node = node.Parent;

                    indexOf = Array.BinarySearch(node.Keys, 0, node.Key_Num, key);
                    if (indexOf < 0)
                    {
                        indexOf = ~indexOf;
                    }

                    if (indexOf == node.Key_Num)
                    {
                        indexOf--;
                    }
                    key = node.Keys[indexOf];
                }
            }

            node          = _reader.Find_Leaf_Node(key, node);
            _current_Node = node;
            _current_Key  = key;

            Current            = key;
            _Current_Has_Value = true;
            return(true);
        }
Esempio n. 3
0
        public bool MoveNext()
        {
            var         node        = _current_Node;
            var         key         = _current_Key;
            long        dataAddress = 0;
            Data <TKey> data;

            if (!_Current_Has_Value)
            {
                if (node.IsClustered)
                {
                    Current = _data_serializer.Get_Instance(node.Get_Clustered_Data(key), 0);
                }
                else
                {
                    dataAddress = node.Get_Data_Address(key);
                    data        = _reader.Read_Data(dataAddress);
                    Current     = _data_serializer.Get_Instance(data.Payload, 0);
                }
                return(_Current_Has_Value = true);
            }

            int indexOf = Array.BinarySearch(node.Keys, 0, node.Key_Num, key) + 1;

            if (indexOf < node.Key_Num)
            {
                key = node.Keys[indexOf];
            }
            else
            {
                while (_current_Key.CompareTo(key) >= 0)
                {
                    if (node.Parent == null)
                    {
                        Current = default(TValue);
                        return(_Current_Has_Value = false);
                    }

                    node = node.Parent;

                    indexOf = Array.BinarySearch(node.Keys, 0, node.Key_Num, key);
                    if (indexOf < 0)
                    {
                        indexOf = ~indexOf;
                    }

                    if (indexOf == node.Key_Num)
                    {
                        indexOf--;
                    }
                    key = node.Keys[indexOf];
                }
            }

            node          = _reader.Find_Leaf_Node(key, node);
            _current_Node = node;
            _current_Key  = key;


            if (node.IsClustered)
            {
                Current = _data_serializer.Get_Instance(node.Get_Clustered_Data(key), 0);
            }
            else
            {
                dataAddress = node.Get_Data_Address(key);
                data        = _reader.Read_Data(dataAddress);
                Current     = _data_serializer.Get_Instance(data.Payload, 0);
            }

            //dataAddress = node.Get_Data_Address(key);
            //data = _reader.Read_Data(dataAddress);
            //Current = _data_serializer.Get_Instance(data.Payload, 0);
            return(_Current_Has_Value = true);
        }