public static State UnpackNewestEventArchive(ImList <EventArchive> eventArchives, State state) { return(state & Store.UpdateGameState(eventArchives[0].Snapshot) & Store.UpdateEventStoreList((Store.GetEventStoreList(state) * eventArchives[0].Archive) & Im.Sort) & Store.UpdateEventArchives(Im.Tail(eventArchives)) ); }
public static EventParameters operator +(EventParameter parameter1, EventParameter parameter2) { var parameterList = new ImList <EventParameter>() + parameter1 + parameter2 ; return(new EventParameters(parameterList)); }
public EventArchive( ImList <Event> archive, float archivedUntil, GameState snapshot ) { Archive = archive; ArchivedUntil = archivedUntil; Snapshot = snapshot; }
public static State OverlayOnEventStoreList(ImList <Event> eventList, State state) { var eventStoreList = Store.GetEventStoreList(state); return(Store.UpdateEventStoreList( eventList & Im.Overlay((evnt1, evnt2) => evnt1.Equals(evnt2), eventStoreList) & Im.Sort , state )); }
public void Map_x() { var l = ImList.List(5, 6, 7); var ml = l.Map((_, i) => i); CollectionAssert.AreEqual(new[] { 0, 1, 2 }, ml.ToArray()); var z = ImZipper.Zip(5, 6, 7); var mz = z.Map((_, i) => i); CollectionAssert.AreEqual(new[] { 0, 1, 2 }, mz.ToArray()); }
public ImList <int>[] AllMoveOptions() { if (FirstRollResult == SecondRollResult) { return new [] { ImList <int> .Create(Enumerable.Repeat(FirstRollResult, 4)) } } ; return(new [] { ImList <int> .Create(FirstRollResult, SecondRollResult), ImList <int> .Create(SecondRollResult, FirstRollResult) }); } }
public void Scenario4ImList() { var l = new ImList <D>(); for (int idx = 1; idx <= cntAdd; idx++) { l = l.Add(new D(idx)); } for (int idx = 1; idx <= cntRead; idx++) { var a = l.ToArray(); if (a.Length != cntAdd) { throw new Exception($"{a.Length} != {cntAdd}"); } } }
private IEnumerable <ImList <SingleGameMove> > MoveOptions(ImList <int> moves, GameColor player) { if (moves.IsNil) { yield return(ImList <SingleGameMove> .Nil); } else { foreach (var firstMove in this.SingleMoveOptions(moves.HeadUnsafe, player)) { foreach (var restMoves in this.DoSingleMove(firstMove).MoveOptions(moves.TailUnsafe, player)) { yield return(ImList <SingleGameMove> .Cons(firstMove, restMoves)); } } } }
public State( string me, Event processing, EventStore eventStore, ImList <EventArchive> eventArchives, GameState gameState, UIState uiState, ImList <RenderCommand> renderData ) { Me = me; Processing = processing; ActiveEventStore = eventStore; EventArchives = eventArchives; CurrentGameState = gameState; CurrentUIState = uiState; RenderData = renderData; }
public void Scenario4ImListLock() { var lst = new ImList <D>(); var datas = GetDatas(); Run( () => { foreach (var d in datas.datas1) { lock (this) { var ll = System.Threading.Volatile.Read(ref lst); ll = ll.Add(d); System.Threading.Volatile.Write(ref lst, ll); System.Threading.Interlocked.MemoryBarrier(); } eatTime(); } }, () => { foreach (var d in datas.datas2) { lock (this) { var ll = System.Threading.Volatile.Read(ref lst); ll = ll.Add(d); System.Threading.Volatile.Write(ref lst, ll); System.Threading.Interlocked.MemoryBarrier(); } eatTime(); } } ); for (int idx = 1; idx <= cntRead; idx++) { var a = lst.ToArray(); if (a.Length != 2 * cntAdd) { throw new Exception($"{a.Length} != 2*{cntAdd}"); } } }
public ReceivePackageEvent(EventId eventId, string progress, ImList <Event> events) : base(eventId) { Progress = progress; Events = events; }
public EventStore(ImList <Event> store, ImList <Event> outbox, string progressId) { Store = store; Outbox = outbox; ProgressId = progressId; }
public void Can_map_with_index() => CollectionAssert.AreEqual( new[] { 1, 3, 5, 7 }, ImList.List(1, 2, 3, 4).Map((x, i) => x + i).ToArray());
public static State UpdateRenderData(ImList <RenderCommand> renderData, State state) { state.RenderData = renderData; return(state); }
public EventStore(List <Event> store, List <Event> outbox, string progressId) { Store = new ImList <Event>(store); Outbox = new ImList <Event>(outbox); ProgressId = progressId; }
public EventParameters() { Parameters = new ImList <EventParameter>(); }
public static Func <State, State> UpdateEventArchives(ImList <EventArchive> eventArchives) { return(Curry <ImList <EventArchive>, State, State> .New(UpdateEventArchives)(eventArchives)); }
public static Func <State, State> UnpackNewestEventArchive(ImList <EventArchive> eventArchives) { return(Curry <ImList <EventArchive>, State, State> .New(UnpackNewestEventArchive)(eventArchives)); }
public static Func <State, State> UpdateEventStoreList(ImList <Event> eventStoreList) { return(Curry <ImList <Event>, State, State> .New(UpdateEventStoreList)(eventStoreList)); }
public WholeMove(ImList <SingleGameMove> moves) { Moves = moves; }
public static Func <State, State> OverlayOnEventStoreList(ImList <Event> eventList) { return(Curry <ImList <Event>, State, State> .New(OverlayOnEventStoreList)(eventList)); }
public static ImList <T> ToImList <T>(this IEnumerable <T> @this) { return(ImList <T> .Create(@this)); }
public EventParameters(ImList <EventParameter> parameters) { Parameters = parameters; }
public EventParameters(List <EventParameter> parameters) { Parameters = new ImList <EventParameter>(parameters); }
public void TestMethodImList() { ImList ret = SlackClient.ImControler.List(); Assert.IsTrue(ret.Ok); }
public static State UpdateEventArchives(ImList <EventArchive> eventArchives, State state) { state.EventArchives = eventArchives; return(state); }
public void Can_map() => CollectionAssert.AreEqual( new[] { 2, 4, 6, 8 }, ImList.List(1, 2, 3, 4).Map(i => i * 2).ToArray());
public static void Render(GameObject gameObject, ImList <RenderCommand> renderData) { Im.Fold(HandleRenderCommand, gameObject, renderData); }