public void TestRemoveAndTrim() { var d = new Deque<int>(4); Assert.IsTrue(d.Count == 0); Assert.IsTrue(d.Capacity == 4); d.AddLast(0); d.AddLast(1); d.AddLast(2); d.AddLast(3); d.AddLast(4); d.AddLast(5); Assert.IsTrue(d.Count == 6); Assert.IsTrue(d.Capacity == 8); d.RemoveLast(); d.RemoveLast(); d.RemoveLast(); Assert.IsTrue(d.Count == 3); Assert.IsTrue(d.Capacity == 8); d.TrimExcess(); Assert.IsTrue(d.Count == 3); Assert.IsTrue(d.Capacity == 3); var arr = d.ToArray(); var exp = new int[] { 0, 1, 2 }; Assert.IsTrue(arr.Length == exp.Length); for (int i = 0; i < arr.Length; i++) { Assert.IsTrue(arr[i] == exp[i]); } }
public void ClearPUT([PexAssumeUnderTest]int[] input) { Deque<int> actual = new Deque<int> (input); actual.Clear(); PexAssert.AreEqual(0, actual.Count); }
static void Main() { Deque<int> deque = new Deque<int>(); Deque<object> dequeOfObjects = new Deque<object>(); //dequeOfIntegers.AddFront(5); //dequeOfIntegers.AddBack(10); //int frontRemoved = dequeOfIntegers.RemoveFront(); //int backRemoced = dequeOfIntegers.RemoveBack(); //int frontPeek = dequeOfIntegers.PeekFront(); //int backPeek = dequeOfIntegers.PeekBack(); //int elements = dequeOfIntegers.Count; //int maxCapacity = dequeOfIntegers.Capacity; deque.AddFront(10); deque.AddFront(50); System.Console.WriteLine(deque.Count); deque[0] = 500; System.Console.WriteLine(deque[0]); Deque<int> anotherDeque = new Deque<int>(); anotherDeque.AddFront(5); anotherDeque.AddFront(10); Deque<int> result = deque + anotherDeque; }
public void ContainsPUT([PexAssumeUnderTest]IList<int> values, int val) { PexAssume.IsTrue(values.Contains(val)); Deque<int> actual = new Deque<int> (values); Assert.AreEqual(true, actual.Contains(val)); }
internal static void Main() { Deque<int> deque = new Deque<int>(); deque.PushFirst(3); deque.PushFirst(5); deque.PushFirst(7); deque.PushLast(10); deque.PushLast(13); //The order of elements in Deque is: 7, 5, 3, 10, 13 //This will write on console first element without removing it from Deque -> 7 Console.WriteLine("Peek first element: {0}", deque.PeekFirst()); //This will write on console last element without removing it from Deque -> 13 Console.WriteLine("Peek last element: {0}", deque.PeekLast()); //This will write on console first element and remove it from Deque -> 7 again Console.WriteLine("Pop first element: {0}", deque.PopFirst()); //This will write on console first element and remove it from Deque -> 5 again Console.WriteLine("Pop first element: {0}", deque.PopFirst()); //This will write on console last element and remove it from Deque -> 13 again Console.WriteLine("Pop last element: {0}", deque.PopLast()); //In the deque now you have only two elements -> 3 and 10 }
public void TestAddAndGrow() { var d = new Deque<int>(0); Assert.IsTrue(d.Count == 0); Assert.IsTrue(d.Capacity == 0); d.AddFirst(1); Assert.IsTrue(d.Count == 1); Assert.IsTrue(d.Capacity == 4); d.AddFirst(0); Assert.IsTrue(d.Count == 2); Assert.IsTrue(d.Capacity == 4); d.AddLast(2); d.AddLast(3); Assert.IsTrue(d.Count == 4); Assert.IsTrue(d.Capacity == 4); d.AddLast(4); Assert.IsTrue(d.Count == 5); Assert.IsTrue(d.Capacity == 8); var arr = d.ToArray(); var exp = new int[] { 0, 1, 2, 3, 4 }; Assert.IsTrue(arr.Length == exp.Length); for (int i = 0; i < arr.Length; i++) { Assert.IsTrue(arr[i] == exp[i]); } }
//-------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="UndoBuffer"/> class. /// </summary> public UndoBuffer() { InternalUndoStack = new Deque<IUndoableOperation>(); InternalRedoStack = new Deque<IUndoableOperation>(); UndoStack = new ReadOnlyCollection<IUndoableOperation>(InternalUndoStack); RedoStack = new ReadOnlyCollection<IUndoableOperation>(InternalRedoStack); }
public void ConstructorExample() { var deque = new Deque<string>(); deque.EnqueueHead("cat"); deque.EnqueueHead("dog"); deque.EnqueueHead("canary"); Assert.AreEqual(3, deque.Count); }
public void Should_return_isEmpty_after_ctor() { // arrange var deque = new Deque<string>(); // act // assert Assert.IsTrue(deque.IsEmpty()); }
public void CopyConstructorPUT(int[] input) { Deque<int> actual = new Deque<int>(input); int[] output = new int[input.Length]; actual.CopyTo(output, 0); CollectionAssert.AreEqual(input, output); }
public void CopyConstructorTest() { List<int> original = new List<int> { 12, 123, 1, 90 }; Deque<int> actual = new Deque<int>(original); Deque<int> expected = new Deque<int> { 12, 123, 1, 90 }; CollectionAssert.AreEqual(expected, actual); }
public void Simple() { var deque = new Deque<int>(); Assert.IsFalse(deque.IsReadOnly); deque = GetTestDeque(); Assert.IsFalse(deque.IsReadOnly); }
public void DequeueBackCountNonEmptyDequeTest() { Deque<int> actual = new Deque<int> { 10, 12, 13 }; actual.DequeueBack(); Assert.AreEqual(2, actual.Count); }
public void ClearTest() { Deque<int> actual = new Deque<int> { 12, 45, 321 }; actual.Clear(); Assert.AreEqual(0, actual.Count); }
public void SetUp() { d = new Deque<int>(); q = new Queue<int>(); s = new Stack<int>(); l = new List<int>(); ll = new LinkedList<int>(); }
internal static void TestIfSame(Deque<int> deque, Deque<int> newDeque) { while (deque.Count > 0) { Assert.AreEqual(deque.DequeueHead(), newDeque.DequeueHead()); } Assert.AreEqual(newDeque.Count, 0); }
public void Given_null_item_add_should_throw_NullPointerException() { // arrange var deque = new Deque<string>(); // act // assert Assert.Throws<NullReferenceException>(() => deque.AddFirst(null)); Assert.Throws<NullReferenceException>(() => deque.AddLast(null)); }
public void BackOfEmptyDequeThrowsException() { // Arrange var sut = new Deque<string>(); // Act/Assert Assert.That(() => sut.Back, Throws.Exception.TypeOf<InvalidOperationException>()); }
public void Remove_on_empty_queue_should_throw_NoSuchElementException() { // arrange var deque = new Deque<string>(); // act // assert Assert.Throws<NoSuchElementException>(() => deque.RemoveFirst()); Assert.Throws<NoSuchElementException>(() => deque.RemoveLast()); }
public BulletPool() { _bulletDeque = new Deque<Bullet>(POOL_SIZE); //Initialize the pool. for (int i = 0; i < POOL_SIZE; i++) { _bulletDeque.AddFirst(new Bullet(GameContent.Assets.Images.Ships.Bullets[ShipType.BattleCruiser, ShipTier.Tier1], Vector2.Zero, GameScreen.World, null)); } }
public void Add_element_should_increment_size() { // arrange var deque = new Deque<string>(); // act deque.AddFirst("Item"); deque.AddLast("Item2"); // assert Assert.AreEqual(2, deque.Size()); }
public void AdvancedTestDequeLast() { var deque = new Deque<String>(); var items = new List<string> { "0", "1", "2", "-", "-", "3", "4", "5", "6", "7", "8", "9" }; Assert.AreEqual(0, deque.Size); Assert.IsTrue(deque.IsEmpty); foreach (var item in items) { if (item != "-") { deque.AddLast(item); } else { if (!deque.IsEmpty) { deque.RemoveLast(); } } } var builder = new StringBuilder(); foreach (var item in deque) { builder.Append(item); } Assert.AreEqual("03456789", builder.ToString()); Assert.AreEqual(8, deque.Size); Assert.IsFalse(deque.IsEmpty); while (!deque.IsEmpty) { deque.RemoveLast(); } Assert.AreEqual(0, deque.Size); Assert.IsTrue(deque.IsEmpty); }
public void NewDequeWithElementsHasElements() { // Arrange // Act var sut = new Deque<string>(new []{ "a", "b", "c" }); // Assert Assert.That(sut.Count, Is.EqualTo(3)); Assert.That(sut.IsEmpty, Is.False); Assert.That(sut, Is.EquivalentTo(new[] { "a", "b", "c" })); }
public void Done() { var dequeeque = new Deque<int>(); dequeeque.EnqueueHead(5); dequeeque.EnqueueHead(3); dequeeque.EnqueueHead(2); var visitor = new CompletedTrackingVisitor<int>(); dequeeque.AcceptVisitor(visitor); }
public void NewDequeWithMinimumCapacityHasRightCapacity() { // Arrange // Act var sut = new Deque<string>(10); // Assert Assert.That(sut.Capacity, Is.GreaterThanOrEqualTo(10)); Assert.That(sut.Count, Is.EqualTo(0)); Assert.That(sut.IsEmpty, Is.True); }
public Worker(WorkStealingScheduler scheduler) { this._thread = new Thread(Work); this._thread.Name = "ParallelTasks Worker"; this._thread.IsBackground = true; this._tasks = new Deque<Task>(); this._scheduler = scheduler; this.Gate = new AutoResetEvent(false); Workers.Add(_thread, this); }
internal static Deque<int> GetTestDeque() { var test = new Deque<int>(); for (var i = 0; i < 5; i++) { test.EnqueueHead(i * 3); } return test; }
public void ExceptionArrayTooSmall() { var deque = new Deque<int>(); deque.EnqueueHead(5); deque.EnqueueTail(3); deque.EnqueueTail(2); deque.EnqueueHead(55); var array = new int[3]; deque.CopyTo(array, 0); }
public void ExceptionNotEnoughSpaceFromIndex() { var deque = new Deque<int>(); deque.EnqueueHead(5); deque.EnqueueTail(3); deque.EnqueueTail(2); deque.EnqueueHead(55); var array = new int[4]; deque.CopyTo(array, 1); }
public void NewDequeIsEmptyWithNonZeroCapacity() { // Arrange // Act var sut = new Deque<string>(); // Assert Assert.That(sut.Capacity, Is.GreaterThan(0)); Assert.That(sut.Count, Is.EqualTo(0)); Assert.That(sut.IsEmpty, Is.True); }
public static IList <T> GetReverseView <T>(Deque <T> d) { return((IList <T>)d.GetReverseView()); }
public void Setup() { _buffer = new Deque <int>(); }
public SmallDeque() { small = new Deque <string>(); BackPushAll(small, "try", "catch", "for", "while", "foreach"); }
public override bool RemoveView(View view) { if (!(view is GroupableView)) { base.RemoveView(view); } var removed = base.RemoveView(view); if (!removed) { return(false); } if (!HasViews) { _subViewsPerKey.Clear(); return(true); } var removedView = (GroupableView)view; Deque <Object> removedKeys = null; foreach (var entry in _subViewsPerKey) { var value = entry.Value.SubviewHolder; if (value is View) { var subview = (GroupableView)value; if (CompareViews(subview, removedView)) { if (removedKeys == null) { removedKeys = new ArrayDeque <Object>(); } removedKeys.Add(entry.Key); } } else if (value is IList <View> ) { var subviews = (IList <View>)value; for (var i = 0; i < subviews.Count; i++) { var subview = (GroupableView)subviews[i]; if (CompareViews(subview, removedView)) { subviews.RemoveAt(i); if (subviews.IsEmpty()) { if (removedKeys == null) { removedKeys = new ArrayDeque <Object>(); } removedKeys.Add(entry.Key); } break; } } } } if (removedKeys != null) { foreach (var key in removedKeys) { _subViewsPerKey.Remove(key); } } return(true); }
public void ContainsReturnsTrueIfDequeHasItem() { var deque = new Deque <Int32>(new[] { 1, 2, 3 }); Assert.True(deque.Contains(2)); }
public OverheadDamage(GameObject parent) { Parent = parent; _messages = new Deque <TextObject>(); }
private Viewable HandleSimpleSelect( Viewable view, ResultSetProcessor resultSetProcessor, AgentInstanceContext agentInstanceContext, EvalRootMatchRemover evalRootMatchRemover, bool suppressSameEventMatches, bool discardPartialsOnMatch) { var finalView = view; // Add filter view that evaluates the filter expression if (_statementSpec.FilterRootNode != null) { var filterView = new FilterExprView(_statementSpec.FilterRootNode, _statementSpec.FilterRootNode.ExprEvaluator, agentInstanceContext); finalView.AddView(filterView); finalView = filterView; } Deque <EPStatementDispatch> dispatches = null; if (evalRootMatchRemover != null && (suppressSameEventMatches || discardPartialsOnMatch)) { var v = new PatternRemoveDispatchView(evalRootMatchRemover, suppressSameEventMatches, discardPartialsOnMatch); dispatches = new ArrayDeque <EPStatementDispatch>(2); dispatches.Add(v); finalView.AddView(v); finalView = v; } // for ordered deliver without output limit/buffer if (_statementSpec.OrderByList.Length > 0 && (_statementSpec.OutputLimitSpec == null)) { var bf = new SingleStreamDispatchView(); if (dispatches == null) { dispatches = new ArrayDeque <EPStatementDispatch>(1); } dispatches.Add(bf); finalView.AddView(bf); finalView = bf; } if (dispatches != null) { var handle = agentInstanceContext.EpStatementAgentInstanceHandle; if (dispatches.Count == 1) { handle.OptionalDispatchable = dispatches.First; } else { EPStatementDispatch[] dispatchArray = dispatches.ToArray(); handle.OptionalDispatchable = new ProxyEPStatementDispatch() { ProcExecute = () => { foreach (var dispatch in dispatchArray) { dispatch.Execute(); } }, }; } } View selectView = _outputProcessViewFactory.MakeView(resultSetProcessor, agentInstanceContext); finalView.AddView(selectView); finalView = selectView; return(finalView); }
public void Init() { StateQue = new Deque <byte[]>(); EarliestTimeStamp = LatestTimeStamp = 0; }
public static ExprDotEvalDTMethodDesc ValidateMake( StreamTypeService streamTypeService, Deque <ExprChainedSpec> chainSpecStack, DatetimeMethodEnum dtMethod, String dtMethodName, EPType inputType, IList <ExprNode> parameters, ExprDotNodeFilterAnalyzerInput inputDesc, TimeZoneInfo timeZone) { // verify input String message = "Date-time enumeration method '" + dtMethodName + "' requires either a DateTime or long value as input or events of an event type that declares a timestamp property"; if (inputType is EventEPType) { if (((EventEPType)inputType).EventType.StartTimestampPropertyName == null) { throw new ExprValidationException(message); } } else { if (!(inputType is ClassEPType || inputType is NullEPType)) { throw new ExprValidationException(message + " but received " + EPTypeHelper.ToTypeDescriptive(inputType)); } if (inputType is ClassEPType) { ClassEPType classEPType = (ClassEPType)inputType; if (!TypeHelper.IsDateTime(classEPType.Clazz)) { throw new ExprValidationException( message + " but received " + classEPType.Clazz.GetTypeNameFullyQualPretty()); } } } IList <CalendarOp> calendarOps = new List <CalendarOp>(); ReformatOp reformatOp = null; IntervalOp intervalOp = null; DatetimeMethodEnum currentMethod = dtMethod; IList <ExprNode> currentParameters = parameters; String currentMethodName = dtMethodName; // drain all calendar ops ExprDotNodeFilterAnalyzerDesc filterAnalyzerDesc = null; while (true) { // handle the first one only if its a calendar op var evaluators = GetEvaluators(currentParameters); var opFactory = currentMethod.MetaData().OpFactory; // compile parameter abstract for validation against available footprints var footprintProvided = DotMethodUtil.GetProvidedFootprint(currentParameters); // validate parameters DotMethodUtil.ValidateParametersDetermineFootprint( currentMethod.Footprints(), DotMethodTypeEnum.DATETIME, currentMethodName, footprintProvided, DotMethodInputTypeMatcherImpl.DEFAULT_ALL); if (opFactory is CalendarOpFactory) { CalendarOp calendarOp = ((CalendarOpFactory)opFactory).GetOp(currentMethod, currentMethodName, currentParameters, evaluators); calendarOps.Add(calendarOp); } else if (opFactory is ReformatOpFactory) { reformatOp = ((ReformatOpFactory)opFactory).GetOp(timeZone, currentMethod, currentMethodName, currentParameters); // compile filter analyzer information if there are no calendar ops in the chain if (calendarOps.IsEmpty()) { filterAnalyzerDesc = reformatOp.GetFilterDesc(streamTypeService.EventTypes, currentMethod, currentParameters, inputDesc); } else { filterAnalyzerDesc = null; } } else if (opFactory is IntervalOpFactory) { intervalOp = ((IntervalOpFactory)opFactory).GetOp(streamTypeService, currentMethod, currentMethodName, currentParameters, evaluators); // compile filter analyzer information if there are no calendar ops in the chain if (calendarOps.IsEmpty()) { filterAnalyzerDesc = intervalOp.GetFilterDesc(streamTypeService.EventTypes, currentMethod, currentParameters, inputDesc); } else { filterAnalyzerDesc = null; } } else { throw new IllegalStateException("Invalid op factory class " + opFactory); } // see if there is more if (chainSpecStack.IsEmpty() || !DatetimeMethodEnumExtensions.IsDateTimeMethod(chainSpecStack.First.Name)) { break; } // pull next var next = chainSpecStack.RemoveFirst(); currentMethod = DatetimeMethodEnumExtensions.FromName(next.Name); currentParameters = next.Parameters; currentMethodName = next.Name; if ((reformatOp != null || intervalOp != null)) { throw new ExprValidationException("Invalid input for date-time method '" + next.Name + "'"); } } ExprDotEval dotEval; EPType returnType; dotEval = new ExprDotEvalDT(calendarOps, timeZone, reformatOp, intervalOp, EPTypeHelper.GetClassSingleValued(inputType), EPTypeHelper.GetEventTypeSingleValued(inputType)); returnType = dotEval.TypeInfo; return(new ExprDotEvalDTMethodDesc(dotEval, returnType, filterAnalyzerDesc)); }
public void ExceptionNullArray() { var deque = new Deque <int>(); Assert.Throws <ArgumentNullException>(() => deque.CopyTo(null, 0)); }
public void PeekRightThrowsExceptionWhenEmpty() { var deque = new Deque <Int32>(); Assert.Throws <InvalidOperationException>(() => deque.PeekRight()); }
public static void AddStep(uint serial, byte speed, Direction movingDir, Direction facingDir, ushort x, ushort y, sbyte z) { Item item = World.Items.Get(serial); if (item == null || item.IsDestroyed) { return; } if (!_steps.TryGetValue(serial, out var deque)) { deque = new Deque <BoatStep>(); _steps[serial] = deque; } while (deque.Count >= Constants.MAX_STEP_COUNT) { deque.RemoveFromFront(); } GetEndPosition( item, deque, out ushort currX, out ushort currY, out sbyte currZ, out Direction endDir); if (currX == x && currY == y && currZ == z && endDir == movingDir) { return; } if (deque.Count == 0) { Console.WriteLine("SET TIMER"); item.LastStepTime = Time.Ticks; } Direction moveDir = DirectionHelper.CalculateDirection(currX, currY, x, y); BoatStep step = new BoatStep(); step.Serial = serial; step.Time = Time.Ticks; step.Speed = speed; if (moveDir != Direction.NONE) { if (moveDir != endDir) { step.X = currX; step.Y = currY; step.Z = currZ; step.MovingDir = moveDir; deque.AddToBack(step); } step.X = x; step.Y = y; step.Z = z; step.MovingDir = moveDir; deque.AddToBack(step); } if (moveDir != movingDir) { step.X = x; step.Y = y; step.Z = z; step.MovingDir = movingDir; deque.AddToBack(step); } Console.WriteLine(">>> STEP ADDED {0}", speed); }
public void StressTest() { _shadow = new List <Int32>(new[] { 1, 2, 3, 4 }); _deque = new Deque <Int32>(new[] { 1, 2, 3, 4 }); var generator = new RandomOpGenerator(); var rnd = new Random(); const Int32 operationsCount = 100000; for (var i = 0; i < operationsCount; i++) { //mutate deque if (i % 300 == 0) { //clear every 300 mutations _deque.Clear(); _shadow.Clear(); } else if (i % 200 == 0) { //trim excess every 300 mutations _deque.TrimExcess(); _shadow.TrimExcess(); Assert.AreEqual(_deque.Count, _deque.Capacity); } else { //draw a random operation var op = generator.Pick(); var val = rnd.Next(1000); switch (op) { case Op.PushRight: { val = rnd.Next(1000); _deque.PushRight(val); _shadow.Add(val); break; } case Op.PushLeft: { val = rnd.Next(1000); _deque.PushLeft(val); _shadow.Insert(0, val); break; } case Op.Add: { break; val = rnd.Next(1000); (_deque as ICollection <Int32>).Add(val); _shadow.Add(val); break; } case Op.SetIndex: { break; /* * if (_deque.Count == 0) goto case Op.Add; * * var randomIndex = rnd.Next(_shadow.Count); * val = rnd.Next(1000); * _deque[randomIndex] = val; * _shadow[randomIndex] = val; * break; */ } case Op.PopLeft: { if (_deque.Count == 0) { goto case Op.PushLeft; } Assert.DoesNotThrow(() => val = _deque.PopLeft()); Assert.AreEqual(_shadow.First(), val); _shadow.RemoveAt(0); break; } case Op.PopRight: { if (_deque.Count == 0) { goto case Op.PushRight; } Assert.DoesNotThrow(() => val = _deque.PopRight()); Assert.AreEqual(_shadow.Last(), val); _shadow.RemoveAt(_shadow.Count - 1); break; } case Op.Remove: { break; if (_deque.Count == 0) { goto case Op.Add; } //draw a random item var index = rnd.Next(_shadow.Count); var item = _shadow[index]; Assert.True((_deque as ICollection <Int32>).Remove(item)); _shadow.Remove(item); break; } } } VerifyEmpty(); VerifyCount(); VerifySequence(); VerifyEnds(); VerifyCapacity(); VerifyIndexer(); } }
public void ExceptionEmpty() { var deque = new Deque <int>(); Assert.AreEqual(deque.Head, 15); }
public DebugView(Deque <T> deque) => this.deque = deque;
public CacheSimulator() { m_NbHits = 0; m_PushHits = true; m_Cache = new Deque <uint>(); }
public void CopyToWithNullArrayThrowsException() { var deque = new Deque <Int32>(new[] { 1, 2, 3 }); Assert.Throws <ArgumentNullException>(() => deque.CopyTo(null, 0)); }
static void Main(string[] args) { // LinkedLIsts<int> Lists = new LinkedLIsts<int>(); // Lists.Add(12); // Lists.Add(6); // Lists.Add(64); // Lists.Add(124); // Lists.Add(256); // Lists.Add(512); // Lists.Add(1084); // // System.Console.WriteLine(Lists.Size() + " Lists Size"); // Lists.GetChain(); // Lists.Remove(0); CustomQueue <int> Queuery = new CustomQueue <int>(); Queuery.Add(14); Queuery.Add(18); Queuery.Add(19); Queuery.Add(20); Queuery.Add(21); Queuery.Remove(); StackBasedOnArray <int> StackOnArray = new StackBasedOnArray <int>(); StackOnArray.Push(15); StackOnArray.Push(20); StackOnArray.Push(25); StackOnArray.Pop(); StackOnArray.Pop(); StackOnArray.Push(30); StackOnArray.Push(35); Deque <int> DeDeque = new Deque <int>(); DeDeque.Push(15); DeDeque.Push(20); DeDeque.Push(25); // get initial size: // System.Console.WriteLine(DeDeque.DequeSize() + " size start"); // should be return * 15 * // System.Console.WriteLine(DeDeque.TakeFirst()); // remove one: // DeDeque.Pop(); // should be return * 15 * // System.Console.WriteLine(DeDeque.TakeFirst()); // Shift method testing... DeDeque.Shift(11); DeDeque.Push(30); DeDeque.Shift(7); DeDeque.Pop(); System.Console.WriteLine(DeDeque.TakeLast()); // should be return * 11 * // System.Console.WriteLine(DeDeque.TakeFirst()); System.Console.WriteLine(DeDeque.DequeSize() + " size start"); System.Console.WriteLine(DeDeque.TakeFirst()); DeDeque.Unshift(); System.Console.WriteLine(DeDeque.TakeFirst()); System.Console.WriteLine(DeDeque.DequeSize() + " size FINISH"); DeDeque.Shift(173); System.Console.WriteLine(DeDeque.TakeFirst()); DeDeque.Push(190); System.Console.WriteLine(DeDeque.TakeFirst()); System.Console.WriteLine(DeDeque.TakeLast()); // get updated size: * 3 * // System.Console.WriteLine(DeDeque.DequeSize() + " size finish"); }
public void ContainsReturnsFalseIfDequeDoesNotHaveItem() { var deque = new Deque <Int32>(new[] { 1, 2, 3 }); Assert.False(deque.Contains(4)); }
/// <summary> /// Create a new instance. /// </summary> /// <param name="channel">the <see cref="IChannel"/> which will have the <see cref="IChannel.IsWritable"/> reflect the amount of queued /// buffers or <c>null</c> if there is no writability state updated.</param> /// <param name="initSize">the initial size of the underlying queue.</param> protected AbstractCoalescingBufferQueue(IChannel channel, int initSize) { _bufAndListenerPairs = new Deque <object>(initSize); _tracker = channel is null ? null : PendingBytesTracker.NewTracker(channel); }
private AnyDeque(Deque <string> deque) { this.deque = deque; }
public void ExceptionEmpty() { var deque = new Deque <int>(); var i = deque.Tail; }
public static Queue <T> asLifoQueue <T>(Deque <T> prm1) { return(default(Queue <T>)); }
public void Analyze(Deque <AnalysisUnit> queue, CancellationToken cancel, Action <int> reportQueueSize = null, int reportQueueInterval = 1) { if (cancel.IsCancellationRequested) { return; } try { // Including a marker at the end of the queue allows us to see in // the log how frequently the queue empties. var endOfQueueMarker = new AnalysisUnit(null, null); int queueCountAtStart = queue.Count; int reportInterval = reportQueueInterval - 1; if (queueCountAtStart > 0) { queue.Append(endOfQueueMarker); } while (queue.Count > 0 && !cancel.IsCancellationRequested) { _unit = queue.PopLeft(); if (_unit == endOfQueueMarker) { AnalysisLog.EndOfQueue(queueCountAtStart, queue.Count); if (reportInterval < 0 && reportQueueSize != null) { reportQueueSize(queue.Count); } queueCountAtStart = queue.Count; if (queueCountAtStart > 0) { queue.Append(endOfQueueMarker); } continue; } AnalysisLog.Dequeue(queue, _unit); if (reportInterval == 0 && reportQueueSize != null) { reportQueueSize(queue.Count); reportInterval = reportQueueInterval - 1; } else if (reportInterval > 0) { reportInterval -= 1; } _unit.IsInQueue = false; SetCurrentUnit(_unit); AnalyzedEntries.Add(_unit.ProjectEntry); _unit.Analyze(this, cancel); } if (reportQueueSize != null) { reportQueueSize(0); } if (cancel.IsCancellationRequested) { AnalysisLog.Cancelled(queue); } } finally { AnalysisLog.Flush(); AnalyzedEntries.Remove(null); } }
public void Teardown() { _buffer.Clear(); _buffer = null; }
public void Reset() { it.Reset(); resBuf = new Deque <UChar>(); }
public AsyncAutoResetEvent(bool initialState = false) { this.queue = new Deque <TaskCompletionSource <object> >(); this.signaled = initialState; }
public void Dispose() { it.Dispose(); resBuf = null; }
void Update() { if (!_f.IsCreated) { Debug.Log("creating"); _f = new Funnel(64, Allocator.Persistent); } var portals = Portals.Take(Amount == 0 ? Portals.Length : math.min(Amount, Portals.Length)).ToArray(); foreach (var portal in portals) { DebugUtil.DrawCircle(portal.position, Radius); } for (int i = 2; i < portals.Length; i++) { DebugUtil.DrawLine(portals[i - 2].position, portals[i - 1].position, Color.green); DebugUtil.DrawLine(portals[i - 2].position, portals[i].position); DebugUtil.DrawLine(portals[i - 1].position, portals[i].position); // if (i == 3 || i == 4) // DebugUtil.DrawCircle(portals[i - 2].position.TakeXZ(), portals[i - 1].position.TakeXZ(), portals[i].position.TakeXZ(), i == 3 ? Color.black : Color.blue); } // DebugUtil.DrawLine(V0.position, Portals[0].position); // DebugUtil.DrawLine(V0.position, Portals[1].position); var l1 = portals.Select(t => t.position.xz()).ToList(); var start = Begin.position.xz(); var l = new System.Collections.Generic.List <Gate>(); var b = true; for (int j = 0; j < l1.Count - 1; j++) { l.Add(b ? new Gate { Left = l1[j], Right = l1[j + 1] } : new Gate { Left = l1[j + 1], Right = l1[j] }); b = !b; } var end = End.position.xz(); var ll = new List <Gate>(64, Allocator.Persistent); foreach (var portal in l) { ll.Add(portal); } var result = new Deque <Funnel.Node>(10, Allocator.Persistent); _f.GetPath(ll, start, end, Radius, result); _waypoints = result.Count; var ra = new Funnel.Node[result.Count]; for (int i = 0; i < result.Count; i++) { ra[i] = result.FromFront(i); } _unique = ra.Distinct().Count(); _path = new StringBuilder().Concat(ra.SelectMany(r => new[] { r.From, r.To })); for (int i = 0; i < ra.Length; ++i) { DebugUtil.DrawLine(ra[i].From.ToXxY(), ra[i].To.ToXxY(), Color.red); } ll.Dispose(); result.Dispose(); }
public static T PeekFirst <T>(this Deque <T> self) => self[0];