Esempio n. 1
0
        /// <summary>
        /// Construct an empty map with a small initial capacity.
        /// </summary>
        public RefMap()
        {
            _prefix = "";
            _packed = RefList <Ref> .emptyList();

            _loose = RefList <Ref> .emptyList();

            _resolved = RefList <Ref> .emptyList();
        }
Esempio n. 2
0
            public void clear()
            {
                _refMap._packed = RefList <Ref> .emptyList();

                _refMap._loose = RefList <Ref> .emptyList();

                _refMap._resolved = RefList <Ref> .emptyList();

                _refMap._size        = 0;
                _refMap._sizeIsValid = true;
            }
Esempio n. 3
0
        public Ref put(string keyName, Ref value)
        {
            string name = toRefName(keyName);

            if (!name.Equals(value.Name))
            {
                throw new ArgumentException("keyName");
            }

            if (!_resolved.isEmpty())
            {
                // Collapse the resolved list into the loose list so we
                // can discard it and stop joining the two together.
                foreach (Ref @ref in _resolved)
                {
                    _loose = _loose.put(@ref);
                }
                _resolved = RefList <Ref> .emptyList();
            }

            int idx = _loose.find(name);

            if (0 <= idx)
            {
                Ref prior = _loose.get(name);
                _loose = _loose.set(idx, value);
                return(prior);
            }
            else
            {
                Ref prior = get(keyName);
                _loose       = _loose.add(idx, value);
                _sizeIsValid = false;
                return(prior);
            }
        }