示例#1
0
        bool find(_Key key, out Image image)
        {
            D.assert(this.validate);

            var entry = this._head;

            while (entry != null)
            {
                if (entry.key == key)
                {
                    image = entry.image;

                    // move to the head of our list, so we purge it last
                    this.release(entry);
                    this.attachToHead(entry);
                    D.assert(this.validate);
                    return(true);
                }

                entry = entry.next;
            }

            D.assert(this.validate);
            image = null;
            return(false);
        }
示例#2
0
        public Image getGradient(List <Color> colors, List <float> positions)
        {
            var key = new _Key(colors, positions);

            if (!this.find(key, out var image))
            {
                image = this.fillGradient(colors, positions);
                this.add(key, image);
            }

            return(image);
        }
示例#3
0
        void add(_Key key, Image image)
        {
            if (this._entryCount == this.maxEntries)
            {
                D.assert(this._tail != null);
                this.release(this._tail);
                this._entryCount--;
            }

            var entry = new _Entry {
                key = key, image = image
            };

            this.attachToHead(entry);
            this._entryCount++;
        }
示例#4
0
 get => _Key; set => SetProperty(ref _Key, value);
示例#5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="key"></param>
 /// <param name="c"></param>
 /// <param name="d"></param>
 public SipHash(_Key key, ushort c = DefaultC, ushort d = DefaultD)
 {
     _key = key;
     _c   = c;
     _d   = d;
 }