public IDeque <T> EnqueueRight(T value) { return((myRight.IsFull) ? new Deque <T>(myLeft, myMiddle.EnqueueRight(myRight), new One(value), myLongCount + 1) : new Deque <T>(myLeft, myMiddle, myRight.EnqueueRight(value), myLongCount + 1) ); }
public IDeque <T> EnqueueRight(T value) { if (!Right.Full) { return(new Deque <T>(Left, Middle, Right.EnqueueRight(value))); } return(new Deque <T>( Left, Middle.EnqueueRight(Right.DequeueRight()), new Two(Right.PeekRight(), value))); }
public void HandleSensorData(SensorData sd) { State origState = state; dataSinceStateStart = dataSinceStateStart.EnqueueRight(sd); ChangeState(sd.FingerCount(), sd.Distance()); if (origState != state) { // state changed! Send off the vanish event for the previous gesture, and a appear event for the current gesture gestures.Enqueue(new Gesture(origState, EventType.VANISH, stateEntryTime, dataSinceStateStart)); stateEntryTime = DateTime.Now; dataSinceStateStart = Deque<SensorData>.Empty; dataSinceStateStart = dataSinceStateStart.EnqueueRight(sd); gestures.Enqueue(new Gesture(state, EventType.APPEAR, stateEntryTime, dataSinceStateStart)); } else { // continuation of the existing gesture gestures.Enqueue(new Gesture(state, EventType.MOVE, stateEntryTime, dataSinceStateStart)); } }