Exemplo n.º 1
0
 public InputPortValue(Node parent, string name, PortDataType type) : base(parent, name, type)
 {
     _values = new CustomSortedList <TimeLocatedValue <T>, TimeStamp>(
         (v) => v.Stamp,
         (k, v) => k.CompareTo(v.Stamp)
         );
 }
Exemplo n.º 2
0
        public LinearSearch(CustomSortedList <T, K> parent, K startKey)
        {
            if (parent == null)
            {
                throw new ArgumentNullException();
            }
            _parent = parent;

            // possible outcomes for binarysearch:
            // index >= 0: meaning, start there
            // index < 0: start at ~index

            _index = parent.BinarySearch(0, parent.Count, startKey);
            if (_index < 0)
            {
                _index = ~_index;
            }

            if (_index >= _parent.Count)
            {
                if (parent.Count == 0)
                {
                    _currentItem = default(T);
                }
                else
                {
                    _currentItem = _parent[parent.Count - 1];
                }
            }
            else
            {
                var cmp = _parent.CompareFunction(startKey, _parent[_index]);
                if (cmp < 0)
                {
                    if (_index == 0)
                    {
                        _currentItem = default(T);
                    }
                    else
                    {
                        _index--;
                        _currentItem = _parent[_index];
                    }
                }
                else
                {
                    _currentItem = _parent[_index];
                }
            }
        }