public override int GetHashCode() { int hash = 1; if (FloatData != 0F) { hash ^= FloatData.GetHashCode(); } if (DoubleData != 0D) { hash ^= DoubleData.GetHashCode(); } if (IntData != 0) { hash ^= IntData.GetHashCode(); } if (LongData != 0L) { hash ^= LongData.GetHashCode(); } if (BoolData != false) { hash ^= BoolData.GetHashCode(); } if (StringData.Length != 0) { hash ^= StringData.GetHashCode(); } hash ^= list_.GetHashCode(); return(hash); }
public void TestPartB() { long[] inputData = new long[] { 35 , 20 , 15 , 25 , 47 , 40 , 62 , 55 , 65 , 95 , 102 , 117 , 150 , 182 , 127 , 219 , 299 , 277 , 309 , 576 }; int preambleLength = 5; int expectedOutput = 62; var data = new LongData(inputData); Day9 day = new Day9(data, preambleLength); var actualOutut = day.Puzzle2Solution(); Assert.AreEqual(expectedOutput, actualOutut); }
private static void SolveDay9() { LongData data = new LongData(".\\Data\\Day9a.txt"); Day9 day = new Day9(data, 25); Console.WriteLine("Day9"); day.SolveToConsole(); Console.WriteLine("Press any key to continue"); Console.ReadKey(); }
public void Handle(INetworkChannel networkChannel, object messagName, LongData roomId, RoomPlayer player) { var e = RoomEvent.AllocEvent <JoinRoomEvent>(); e.HallRoomId = roomId.Value; e.RoomPlayer = player; _dispatcher.AddEvent(e); _logger.InfoFormat("Receive Join Room Message Hall Room Id {0} Map Id {1}", roomId, player.Id); }
private void SendRoomGameStatus(UpdateRoomGameStatusEvent e) { var hallRoomId = LongData.Allocate(); hallRoomId.Value = e.HallRoomId; var rStatus = IntData.Allocate(); rStatus.Value = e.Status; var canEnter = IntData.Allocate(); canEnter.Value = e.CanEnter; SendAndReleaseMessage(RpcMessageType.UpdateRoomGameState, hallRoomId, rStatus, canEnter); }
private void SendJoinRoomFail(JoinRoomResponseEvent e) { _logger.ErrorFormat("JoinRoom Error ... Code:{0}", e.JoinRoomResponseInfo.ErrCode); var rCode = IntData.Allocate(); rCode.Value = (int)e.JoinRoomResponseInfo.ErrCode; var rHallRoomId = LongData.Allocate(); rHallRoomId.Value = e.HallRoomId; var loginPlayer = LoginPlayer.Allocate(); loginPlayer.Id = e.JoinRoomResponseInfo.PlayerId; loginPlayer.Token = ""; SendAndReleaseMessage(RpcMessageType.ResponseJoinRoom, rCode, rHallRoomId, loginPlayer); }
private void SendJoinRoomSuccess(JoinRoomResponseEvent e) { _logger.InfoFormat("JoinRoom Successfully Player Id {0} Token {1}", e.JoinRoomResponseInfo.PlayerId, e.JoinRoomResponseInfo.Token); var loginPlayer = LoginPlayer.Allocate(); loginPlayer.Id = e.JoinRoomResponseInfo.PlayerId; loginPlayer.Token = e.JoinRoomResponseInfo.Token; var rCode = IntData.Allocate(); rCode.Value = e.RetCode; var rHallRoomId = LongData.Allocate(); rHallRoomId.Value = e.HallRoomId; SendAndReleaseMessage(RpcMessageType.ResponseJoinRoom, rCode, rHallRoomId, loginPlayer); }
public void CanMergeZeroDepthData() { var left = new LongData(867); var right = new LongData(5309); var leftData = new List<KeyValuePair<Key, IMergeSource>> { new KeyValuePair<Key, IMergeSource>(new Key(new uint[0]), left), }; var rightData = new List<KeyValuePair<Key, IMergeSource>> { new KeyValuePair<Key, IMergeSource>(new Key(new uint[0]), right), }; var merged = KeyedDataMerge<LongData>.MergeSorted(new[] {leftData, rightData}).ToList(); Assert.AreEqual(1, merged.Count); Assert.AreEqual(left.Value + right.Value, merged[0].Value.Value); }
public void CanMergeZeroDepthData() { var left = new LongData(867); var right = new LongData(5309); var leftData = new List <KeyValuePair <Key, IMergeSource> > { new KeyValuePair <Key, IMergeSource>(new Key(new uint[0]), left), }; var rightData = new List <KeyValuePair <Key, IMergeSource> > { new KeyValuePair <Key, IMergeSource>(new Key(new uint[0]), right), }; var merged = KeyedDataMerge <LongData> .MergeSorted(new[] { leftData, rightData }).ToList(); Assert.AreEqual(1, merged.Count); Assert.AreEqual(left.Value + right.Value, merged[0].Value.Value); }
public void CanMergeDataWhereOneSideIsEmpty() { var firstKey = new LongData(867); var secondKey = new LongData(5309); var fullData = new List <KeyValuePair <Key, IMergeSource> > { new KeyValuePair <Key, IMergeSource>(new Key(new[] { (uint)firstKey.Value }), firstKey), new KeyValuePair <Key, IMergeSource>(new Key(new[] { (uint)secondKey.Value }), secondKey), }; var emptyData = new List <KeyValuePair <Key, IMergeSource> >(); // Validate both left and right being the full side. foreach (var pair in new[] { new[] { fullData, emptyData }, new[] { emptyData, fullData }, }) { var count = 0; foreach (var kvp in KeyedDataMerge <LongData> .MergeSorted(pair)) { ++count; if (kvp.Key.Values[0] == (uint)firstKey.Value) { Assert.AreEqual(firstKey.Value, kvp.Value.Value); } else if (kvp.Key.Values[0] == (uint)secondKey.Value) { Assert.AreEqual(secondKey.Value, kvp.Value.Value); } else { Assert.Fail(); } } Assert.AreEqual(2, count); } }
private void SendMandateLogOutMessage(MandatoryLogOutEvent e) { _logger.InfoFormat("Mandatory Logout Message HallRoom Id {0} Room Id {1} PlayerEntityId {2}", e.HallRoomId, e.RoomId, e.PlayerId); LongData hallRoomId = LongData.Allocate(); hallRoomId.Value = e.HallRoomId; IntData roomId = IntData.Allocate(); roomId.Value = e.RoomId; LongData playerId = LongData.Allocate(); playerId.Value = e.PlayerId; SendAndReleaseMessage(RpcMessageType.MandateLogOut, hallRoomId, roomId, playerId); if (e.LogOutReason == MandatoryLogOutEvent.Reason.GameExit) { _statistic.IsGameOverMandateLogOutSend = true; } }
public void CanMergeDataWhereOneSideIsEmpty() { var firstKey = new LongData(867); var secondKey = new LongData(5309); var fullData = new List<KeyValuePair<Key, IMergeSource>> { new KeyValuePair<Key, IMergeSource>(new Key(new[] {(uint)firstKey.Value}), firstKey), new KeyValuePair<Key, IMergeSource>(new Key(new[] {(uint)secondKey.Value}), secondKey), }; var emptyData = new List<KeyValuePair<Key, IMergeSource>>(); // Validate both left and right being the full side. foreach (var pair in new[] { new[] {fullData, emptyData}, new[] {emptyData, fullData}, }) { var count = 0; foreach (var kvp in KeyedDataMerge<LongData>.MergeSorted(pair)) { ++count; if (kvp.Key.Values[0] == (uint)firstKey.Value) { Assert.AreEqual(firstKey.Value, kvp.Value.Value); } else if (kvp.Key.Values[0] == (uint)secondKey.Value) { Assert.AreEqual(secondKey.Value, kvp.Value.Value); } else { Assert.Fail(); } } Assert.AreEqual(2, count); } }
public Object serializeAnswerData(LongData data) { return(((long)data.Value).ToString()); }