示例#1
0
文件: ITN.cs 项目: 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);
        }
示例#2
0
文件: ITN.cs 项目: 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);
        }