OrderedCollection/*PERMUDA*/Proxy(
    IOrderedCollection/*PERMUDA*//*PERMUDA FROMSUFFIX*/ from
)
{
    NonNull.CheckParameter( from, "from" );
    this.From = from;
}
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TransformCollection&lt;TInt, TExt&gt;"/> class.
 /// </summary>
 /// <param name="orderedCollection">The ordered collection.</param>
 /// <param name="transformExtInt">The transform ext int.</param>
 /// <param name="transformIntExt">The transform int ext.</param>
 public TransformOrderedCollection(
     IOrderedCollection <TInt> orderedCollection,
     Func <TExt, TInt> transformExtInt,
     Func <TInt, TExt> transformIntExt) : base(
         orderedCollection,
         transformExtInt,
         transformIntExt)
 {
     _orderedCollection = orderedCollection;
 }
Пример #3
0
        protected override void PutMany(IOrderedCollection <int, string> collection, params string[] values)
        {
            var pairs = new List <KeyValuePair <int, string> >(values.Length);

            foreach (var value in values)
            {
                pairs.Add(new KeyValuePair <int, string>(Interlocked.Increment(ref _lastKey), value));
            }
            collection.PutMany(pairs);
        }
Пример #4
0
        public SystemManager(World world)
        {
            _World                   = world;
            _ComponentSystems        = new OrderedList <ComponentSystem>();
            _HandledComponentsArrays = new Dictionary <Type, HandledComponents[]>();
            _UpdateStopwatch         = new Stopwatch();

            RegisterLast <FirstOrderSystem>();
            RegisterLast <DefaultOrderSystem>();
            RegisterLast <LastOrderSystem>();
        }
        internal static IOrderedCollection <T> AsOrderedCollection <T>(this IEnumerable <T> sequence)
        {
            Requires.NotNull <IEnumerable <T> >(sequence, "sequence");
            IOrderedCollection <T> orderedCollection = sequence as IOrderedCollection <T>;

            if (orderedCollection != null)
            {
                return(orderedCollection);
            }
            IList <T> list = sequence as IList <T>;

            if (list != null)
            {
                return(new ImmutableExtensions.ListOfTWrapper <T>(list));
            }
            return(new ImmutableExtensions.FallbackWrapper <T>(sequence));
        }
Пример #6
0
            internal static Node NodeTreeFromList(IOrderedCollection <T> items, int start, int length)
            {
                Requires.NotNull(items, nameof(items));
                Debug.Assert(start >= 0);
                Debug.Assert(length >= 0);

                if (length == 0)
                {
                    return(EmptyNode);
                }

                int  rightCount = (length - 1) / 2;
                int  leftCount  = (length - 1) - rightCount;
                Node left       = NodeTreeFromList(items, start, leftCount);
                Node right      = NodeTreeFromList(items, start + leftCount + 1, rightCount);

                return(new Node(items[start + leftCount], left, right, true));
            }
            /// <summary>
            /// Creates a node tree that contains the contents of a list.
            /// </summary>
            /// <param name="items">An indexable list with the contents that the new node tree should contain.</param>
            /// <param name="start">The starting index within <paramref name="items"/> that should be captured by the node tree.</param>
            /// <param name="length">The number of elements from <paramref name="items"/> that should be captured by the node tree.</param>
            /// <returns>The root of the created node tree.</returns>
            private static Node NodeTreeFromList(IOrderedCollection <KeyValuePair <TKey, TValue> > items, int start, int length)
            {
                Requires.NotNull(items, nameof(items));
                Requires.Range(start >= 0, nameof(start));
                Requires.Range(length >= 0, nameof(length));

                if (length == 0)
                {
                    return(EmptyNode);
                }

                int  rightCount = (length - 1) / 2;
                int  leftCount  = (length - 1) - rightCount;
                Node left       = NodeTreeFromList(items, start, leftCount);
                Node right      = NodeTreeFromList(items, start + leftCount + 1, rightCount);
                var  item       = items[start + leftCount];

                return(new Node(item.Key, item.Value, left, right, true));
            }
Пример #8
0
        private static SortedInt32KeyNode <TValue> NodeTreeFromList(IOrderedCollection <KeyValuePair <int, TValue> > items, int start, int length)
        {
            Requires.NotNull(items, "items");
            Requires.Range(start >= 0, "start");
            Requires.Range(length >= 0, "length");

            if (length == 0)
            {
                return(EmptyNode);
            }

            int rightCount = (length - 1) / 2;
            int leftCount  = (length - 1) - rightCount;
            SortedInt32KeyNode <TValue> left  = NodeTreeFromList(items, start, leftCount);
            SortedInt32KeyNode <TValue> right = NodeTreeFromList(items, start + leftCount + 1, rightCount);
            var item = items[start + leftCount];

            return(new SortedInt32KeyNode <TValue>(item.Key, item.Value, left, right, true));
        }
IndexSlice/*PERMUDA*/(
    IOrderedCollection/*PERMUDA*//*PERMUDA TYPESUFFIX*/ from,
    ///< The underlying collection
    long                        sliceIndex,
    ///< Index at which the slice begins
    ///  - <tt>GTE( 0 )</tt>
    ///  - <tt>LTE( from.Count )</tt>
    long                        sliceCount
    ///< Length of the slice
    ///  - <tt>GTE( 0 )</tt>
    ///  - <tt>LTE( from.Count - sliceIndex )</tt>
)
{
    NonNull.CheckParameter( from, "from" );
    GTE.CheckParameter( 0, sliceIndex, "sliceIndex" );
    LTE.CheckParameter( from.Count, sliceIndex, "sliceIndex" );
    GTE.CheckParameter( 0, sliceCount, "sliceCount" );
    LTE.CheckParameter( from.Count - sliceIndex, sliceCount, "sliceCount" );
    this.From = from;
    this.SliceIndex = sliceIndex;
    this.SliceCount = sliceCount;
}
 /// <summary>
 ///     Returns the sorted collection.
 /// </summary>
 /// <typeparam name="T">
 ///     The data type of the collection.
 /// </typeparam>
 /// <param name="collection">
 ///     The sorted collection definition.
 /// </param>
 /// <returns>
 ///     The sorted collection.
 /// </returns>
 internal static IQueryable <T> GetCollection <T>(this IOrderedCollection <T> collection) where T : class
 {
     return(((OrderedCollection <T>)collection).GetCollection());
 }
Пример #11
0
 protected override void RemoveLastPutValue(IOrderedCollection <int, string> collection)
 {
     collection.RemoveRange(Interval.Create(_lastKey, _lastKey));
 }
Пример #12
0
 protected override void Put(IOrderedCollection <int, string> collection, string value)
 {
     collection.Put(Interlocked.Increment(ref _lastKey), value);
 }