Insert() public method

public Insert ( value ) : PQHandle
return PQHandle
示例#1
0
        public PQHandle Insert(TValue value)
        {
            if (_initialized)
            {
                return(_heap.Insert(value));
            }
            int size = _size;

            if (++_size >= _max)
            {
                _max <<= 1;
                Array.Resize(ref _keys, _max);
            }
            _keys[size] = value;
            PQHandle result = default(PQHandle);

            result._handle = -(size + 1);
            return(result);
        }
示例#2
0
        public PQHandle Insert(TValue value)
        {
            if (_initialized)
            {
                return(_heap.Insert(value));
            }

            int curr = _size;

            if (++_size >= _max)
            {
                _max <<= 1;
                Array.Resize(ref _keys, _max);
            }

            _keys[curr] = value;
            return(new PQHandle {
                _handle = -(curr + 1)
            });
        }