Пример #1
0
 public static SCG.IEnumerable <T> SkipIndex <T>(this SCG.IEnumerable <T> enumerable, int index)
 => enumerable.SkipRange(index, 1);
Пример #2
0
 private void RandomBoardLayout(SCG.IEnumerable <Tile> tiles, SCG.IEnumerable <HexTile> hexes, int x, int y, int maxd)
 {
     RandomBoardLayout(tiles, hexes, x, y, x, y, maxd, maxd);
 }
Пример #3
0
        /// <summary>
        /// Remove all items *not* in a supplied collection from this bag,
        /// counting multiplicities.
        /// </summary>
        /// <param name="items">The items to retain</param>
        public virtual void RetainAll(SCG.IEnumerable <T> items)
        {
            UpdateCheck();

            HashBag <T> res = new HashBag <T>(itemequalityComparer);

            foreach (T item in items)
            {
                SCG.KeyValuePair <T, int> p = new SCG.KeyValuePair <T, int>(item, default);
                if (dict.Find(ref p))
                {
                    SCG.KeyValuePair <T, int> q = p;
                    if (res.dict.Find(ref q))
                    {
                        if (q.Value < p.Value)
                        {
                            q = new SCG.KeyValuePair <T, int>(q.Key, q.Value + 1);
                            res.dict.Update(q);
                            res.size++;
                        }
                    }
                    else
                    {
                        q = new SCG.KeyValuePair <T, int>(q.Key, 1);
                        res.dict.Add(q);
                        res.size++;
                    }
                }
            }

            if (size == res.size)
            {
                return;
            }

            CircularQueue <T> wasRemoved = null;

            if ((ActiveEvents & EventType.Removed) != 0)
            {
                wasRemoved = new CircularQueue <T>();
                foreach (SCG.KeyValuePair <T, int> p in dict)
                {
                    int removed = p.Value - res.ContainsCount(p.Key);
                    if (removed > 0)
                    {
#warning We could send bag events here easily using a CircularQueue of (should?)
                        for (int i = 0; i < removed; i++)
                        {
                            wasRemoved.Enqueue(p.Key);
                        }
                    }
                }
            }
            dict = res.dict;
            size = res.size;

            if ((ActiveEvents & EventType.Removed) != 0)
            {
                RaiseForRemoveAll(wasRemoved);
            }
            else if ((ActiveEvents & EventType.Changed) != 0)
            {
                RaiseCollectionChanged();
            }
        }
Пример #4
0
 protected override SCG.IEnumerable <T> GetEnumerable <T>(SCG.IEnumerable <T> enumerable) => GetCollectionValue(enumerable);
Пример #5
0
        //TODO: add delegate for checking validity!

        public BasicCollectionValue(SCG.IEnumerable <T> e, Func <T> chooser, int c)
        {
            enumerable = e; count = c; this.chooser = chooser;
        }
Пример #6
0
 public abstract bool ContainsRange(SCG.IEnumerable <T> items);
Пример #7
0
 public abstract bool RetainRange(SCG.IEnumerable <T> items);
Пример #8
0
 public void RetainAll <U>(SCG.IEnumerable <U> items) where U : K
 {
     throw new ReadOnlyCollectionException();
 }
Пример #9
0
 public RankedNode(SCG.IEnumerable <RankedNode> peers, RankedNode leader) : this()
 {
     Leader = leader;
     Connect(peers);
 }
Пример #10
0
        //TODO: add delegate for checking validity!

        public BasicCollectionValue(SCG.IEnumerable <T> e, Func <T> chooser, int c)
        {
            _enumerable = e;
            _chooser    = chooser;
            Count       = c;
        }
Пример #11
0
 public void AddSorted <U>(SCG.IEnumerable <U> items) where U : K
 {
     throw new ReadOnlyCollectionException();
 }
Пример #12
0
 public BadEnumerable(SCG.IEnumerable <T> enumerable, Exception exception = null)
 {
     _enumerable = enumerable;
     _exception  = exception ?? new BadEnumerableException();
 }
Пример #13
0
 public void WriteLine <T>(SCG.IEnumerable <T> ienum)
 {
     OnSettingsChanged();
     Writer.WriteLine <T>(ienum);
 }
Пример #14
0
 public virtual void RemoveAll <U>(SCG.IEnumerable <U> items) where U : T
 {
     RaiseForRemoveAllHandler raiseHandler = new RaiseForRemoveAllHandler();
 }
Пример #15
0
 public static void IsThawed <T>(SCG.IEnumerable <IThawable <T> > freezables) where T : IThawable <T>
 {
     Contract.Ensures(Contract.ForAll(freezables, f => !f.IsFrozen));
 }
 /// <summary>
 /// For testing purposes, we have a "closer" ToList() implementation that returns J2N's list instead of the default.
 /// <para/>
 /// TODO: Make a production extension method (apprpriately named) that can be used instead of ToList()
 /// </summary>
 public static List <T> ToList <T>(this SCG.IEnumerable <T> source)
 {
     return(new List <T>(source));
 }
Пример #17
0
 public abstract bool AddRange(SCG.IEnumerable <T> items);
Пример #18
0
 public LiftedEnumerable(SCG.IEnumerable <H> keys)
 {
     this.keys = keys;
 }
Пример #19
0
 public abstract bool RemoveRange(SCG.IEnumerable <T> items);
Пример #20
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="keys"></param>
 /// <returns></returns>
 public virtual bool ContainsAll <H>(SCG.IEnumerable <H> keys) where H : K
 {
     return(pairs.ContainsAll(new LiftedEnumerable <H>(keys)));
 }
Пример #21
0
 /// <summary>
 ///     Creates a collection value containing the items in the enumerable.
 /// </summary>
 /// <typeparam name="T">
 ///     The type of the items in the collection value.
 /// </typeparam>
 /// <param name="enumerable">
 ///     The collection whose items are copied to the new collection value.
 /// </param>
 /// <param name="allowsNull">
 ///     A value indicating whether the collection allows <c>null</c> items.
 /// </param>
 /// <returns>
 ///     A collection value containing the items in the enumerable.
 /// </returns>
 protected abstract ICollectionValue <T> GetCollectionValue <T>(SCG.IEnumerable <T> enumerable, bool allowsNull = false);
Пример #22
0
 protected override IList <T> GetList <T>(SCG.IEnumerable <T> enumerable, SCG.IEqualityComparer <T> equalityComparer = null, bool allowsNull = false)
 => new LinkedList <T>(enumerable, equalityComparer, allowsNull);
Пример #23
0
 /// <summary>
 ///     Creates a enumerable containing the items in another enumerable.
 /// </summary>
 /// <typeparam name="T">
 ///     The type of the items in the enumerable.
 /// </typeparam>
 /// <param name="enumerable">
 ///     The collection whose items are copied to the new enumerable.
 /// </param>
 /// <returns>
 ///     A enumerable containing the items in another enumerable.
 /// </returns>
 protected abstract SCG.IEnumerable <T> GetEnumerable <T>(SCG.IEnumerable <T> enumerable);
Пример #24
0
 protected override IStack <T> GetStack <T>(SCG.IEnumerable <T> enumerable, bool allowsNull = false)
 => new LinkedList <T>(enumerable, allowsNull: allowsNull);
Пример #25
0
 public Set(SCG.IEnumerable <T> enm) : base()
 {
     AddAll(enm);
 }
Пример #26
0
 public void AddAll(SCG.IEnumerable <K> items)
 {
     throw new ReadOnlyCollectionException();
 }
Пример #27
0
 void IExtensible <int> .AddAll(SCG.IEnumerable <int> enumerable)
 {
     throw new NotImplementedException();
 }
Пример #28
0
 public static void ChildrenThawed <T>(SCG.IEnumerable <IThawable <T> > children, bool thawChildren) where T : IThawable <T>
 {
     Contract.Ensures(!thawChildren || Contract.ForAll(children, child => !child.IsFrozen));
 }
Пример #29
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="items"></param>
 public void AddSorted(SCG.IEnumerable <KeyValuePair <K, V> > items)
 {
     sortedpairs.AddSorted(items);
 }
Пример #30
0
 public static bool HasSameAs <T>(this SCG.IEnumerable <T> enumerable, SCG.IEnumerable <T> otherEnumerable)
 => enumerable.UnsequenceEqual(otherEnumerable, GetIdenticalityComparer <T>());