Пример #1
0
        /// <summary>
        /// Execute the selector on each chunk queue and return true if all evaluate true. The predicate can safely
        /// remove the current item from the input list during iteration if desired.
        /// </summary>
        /// <param name="chunks">The chunks.</param>
        /// <param name="selector">The chunk queue selector.</param>
        /// <param name="queueMissingAction">Indicates how a non-existing chunk queue is handled when performing an
        /// operation on a chunk.</param>
        /// <returns>True if all chunk queues evaluate true.</returns>
        public bool ForAllChunks(IList chunks, Predicate<ChunkJobQueue> selector, MissingQueue queueMissingAction)
        {
            // Iterate backwards in case the predicate removes the current item from the collection
            for (int i = chunks.Count - 1; i >= 0; i--)
            {
                var chunk = (Vector2I)chunks[i];
                ChunkJobQueue queue;
                if (!this.chunkQueues.TryGetValue(chunk, out queue))
                {
                    switch (queueMissingAction)
                    {
                        case MissingQueue.CreateAndEvaluate:
                            queue = this.InitialiseQueue(chunk);
                            break;

                        case MissingQueue.Skip:
                            continue;

                        case MissingQueue.Fail:
                            return false;
                    }
                }

                if (!selector(queue))
                {
                    return false;
                }
            }

            return true;
        }
Пример #2
0
 /// <summary>
 /// Execute the selector on each chunk queue and return true if all evaluate true. The predicate can safely
 /// remove the current item from the input list during iteration if desired.
 /// </summary>
 /// <param name="chunk">The chunk.</param>
 /// <param name="selector">The chunk queue selector.</param>
 /// <param name="queueMissingAction">Indicates how a non-existing chunk queue is handled when performing an
 /// operation on a chunk.</param>
 /// <returns>True if all chunk queues evaluate true.</returns>
 public bool ForAllChunks(Vector2I chunk, Predicate<ChunkJobQueue> selector, MissingQueue queueMissingAction)
 {
     return this.ForAllChunks(new Vector2I[] { chunk }, selector, queueMissingAction);
 }