Exemplo n.º 1
0
        private IMultiLinkedList <TItem> EnsureList(TGroup group, bool createIfNecessary)
        {
            if (!_dictionary.ContainsKey(group))
            {
                if (createIfNecessary)
                {
                    var list = new MultiLinkedList <TItem>();
                    _dictionary[group] = list;

                    if (_lists.Count > 0)
                    {
                        // Attach the list to our list chain
                        var previous = _lists[_lists.Count - 1];
                        previous.SetNext(list);
                        list.SetPrevious(previous);
                    }

                    _lists.Add(list);
                    return(list);
                }
            }
            else
            {
                return(_dictionary[group]);
            }
            return(null);
        }
Exemplo n.º 2
0
        private IMultiLinkedList <TItem> EnsureList(TGroup group)
        {
            if (group == null)
            {
                return(null);
            }

            if (_dictionary.ContainsKey(group))
            {
                return(_dictionary[group]);
            }

            var list = new MultiLinkedList <TItem>();

            _dictionary[group] = list;

            _lists.Add(list);
            return(list);
        }