Example #1
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);
            }
        }
Example #2
0
 /// <summary>
 /// Initialize this list to use the same backing array as another list.
 /// </summary>
 /// <param name="src">the source list</param>
 public RefList(RefList <T> src)
 {
     this._list = src._list;
     this._cnt  = src._cnt;
 }