public static SCG.IEnumerable <T> SkipIndex <T>(this SCG.IEnumerable <T> enumerable, int index) => enumerable.SkipRange(index, 1);
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); }
/// <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(); } }
protected override SCG.IEnumerable <T> GetEnumerable <T>(SCG.IEnumerable <T> enumerable) => GetCollectionValue(enumerable);
//TODO: add delegate for checking validity! public BasicCollectionValue(SCG.IEnumerable <T> e, Func <T> chooser, int c) { enumerable = e; count = c; this.chooser = chooser; }
public abstract bool ContainsRange(SCG.IEnumerable <T> items);
public abstract bool RetainRange(SCG.IEnumerable <T> items);
public void RetainAll <U>(SCG.IEnumerable <U> items) where U : K { throw new ReadOnlyCollectionException(); }
public RankedNode(SCG.IEnumerable <RankedNode> peers, RankedNode leader) : this() { Leader = leader; Connect(peers); }
//TODO: add delegate for checking validity! public BasicCollectionValue(SCG.IEnumerable <T> e, Func <T> chooser, int c) { _enumerable = e; _chooser = chooser; Count = c; }
public void AddSorted <U>(SCG.IEnumerable <U> items) where U : K { throw new ReadOnlyCollectionException(); }
public BadEnumerable(SCG.IEnumerable <T> enumerable, Exception exception = null) { _enumerable = enumerable; _exception = exception ?? new BadEnumerableException(); }
public void WriteLine <T>(SCG.IEnumerable <T> ienum) { OnSettingsChanged(); Writer.WriteLine <T>(ienum); }
public virtual void RemoveAll <U>(SCG.IEnumerable <U> items) where U : T { RaiseForRemoveAllHandler raiseHandler = new RaiseForRemoveAllHandler(); }
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)); }
public abstract bool AddRange(SCG.IEnumerable <T> items);
public LiftedEnumerable(SCG.IEnumerable <H> keys) { this.keys = keys; }
public abstract bool RemoveRange(SCG.IEnumerable <T> items);
/// <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))); }
/// <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);
protected override IList <T> GetList <T>(SCG.IEnumerable <T> enumerable, SCG.IEqualityComparer <T> equalityComparer = null, bool allowsNull = false) => new LinkedList <T>(enumerable, equalityComparer, allowsNull);
/// <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);
protected override IStack <T> GetStack <T>(SCG.IEnumerable <T> enumerable, bool allowsNull = false) => new LinkedList <T>(enumerable, allowsNull: allowsNull);
public Set(SCG.IEnumerable <T> enm) : base() { AddAll(enm); }
public void AddAll(SCG.IEnumerable <K> items) { throw new ReadOnlyCollectionException(); }
void IExtensible <int> .AddAll(SCG.IEnumerable <int> enumerable) { throw new NotImplementedException(); }
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)); }
/// <summary> /// /// </summary> /// <param name="items"></param> public void AddSorted(SCG.IEnumerable <KeyValuePair <K, V> > items) { sortedpairs.AddSorted(items); }
public static bool HasSameAs <T>(this SCG.IEnumerable <T> enumerable, SCG.IEnumerable <T> otherEnumerable) => enumerable.UnsequenceEqual(otherEnumerable, GetIdenticalityComparer <T>());