Esempio n. 1
0
File: ITN.cs Progetto: Orlys/Pixy
        public bool Decrease(EP endpoint)
        {
            Contract.Null(endpoint, nameof(endpoint));

            foreach (var key in this._table.Keys)
            {
                var current = this._table[key];
                if (current.Equals(endpoint))
                {
                    this._serials.Push(key);
                    this._table[key] = null;
                    this._payload--;
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 2
0
File: ITN.cs Progetto: Orlys/Pixy
        public bool Increase(EP endpoint)
        {
            Contract.Null(endpoint, nameof(endpoint));

            if (this._serials.IsEmpty())
            {
                return(false);
            }
            if (this._table.ContainsValue(endpoint))
            {
                return(false);
            }

            var sn = this._serials.Pop();

            _table[sn] = endpoint;
            this._payload++;

            return(true);
        }