public ReplayerView(FixedSizeList <ReplayerDataModel> dataModelList, IEnumerable <ReplayerDataModel> sessionHandsList, bool showHoleCards) { InitializeComponent(); if (dataModelList == null || dataModelList.Count() == 0 || !dataModelList.Any(x => x.IsActive)) { throw new ArgumentException("Data model list should contain at least one active value", "dataModelList"); } _lastHandsCollection = dataModelList; var dataModel = dataModelList.First(x => x.IsActive); Header = StringFormatter.GetReplayerHeaderString(dataModel.GameType, dataModel.Time); ViewModel.PropertyChanged += ViewModel_PropertyChanged; ViewModel.IsShowHoleCards = showHoleCards; ViewModel.ActivePlayerName = dataModel.Statistic.PlayerName; ViewModel.LastHandsCollection = new ObservableCollection <ReplayerDataModel>(dataModelList); ViewModel.SessionHandsCollection = new ObservableCollection <ReplayerDataModel>(sessionHandsList); ViewModel.CurrentHand = dataModel; ViewModel.ReplayerWindow = this; Loaded += ReplayerView_Loaded; }
public HudWindowViewModel(Dispatcher dispatcher) { this.dispatcher = dispatcher; readerWriterLock = new ReaderWriterLockSlim(); NotificationRequest = new InteractionRequest <INotification>(); layoutsCollection = new ObservableCollection <string>(); ExportHandCommand = new RelayCommand(ExportHand); TagHandCommand = new RelayCommand(TagHand); TagLastHandsCommand = new RelayCommand(TagLastHands); ReplayLastHandCommand = new RelayCommand(ReplayLastHand); LoadLayoutCommand = new RelayCommand(LoadLayout); ApplyPositionsCommand = new RelayCommand(ApplyPositions); TreatAsCommand = new RelayCommand(DoTreatAs); RotateHUDToRightCommand = new RelayCommand(() => RotateHud(true)); RotateHUDToLeftCommand = new RelayCommand(() => RotateHud(false)); panelOffsets = new Dictionary <HudToolKey, Point>(); var tableTypes = Enum.GetValues(typeof(EnumTableType)).Cast <byte>().ToArray(); treatAs = new ObservableCollection <byte>(tableTypes); lastHands = new FixedSizeList <long>(3); }
internal IPv6AddressFamilyView(ref SOCKADDR @base) : base(@base) { Port = @base.IPv6.Port; Bytes = new FixedSizeList <byte>( @base.IPv6.Addr.Byte0, @base.IPv6.Addr.Byte1 , @base.IPv6.Addr.Byte2, @base.IPv6.Addr.Byte3 , @base.IPv6.Addr.Byte4, @base.IPv6.Addr.Byte5 , @base.IPv6.Addr.Byte6, @base.IPv6.Addr.Byte7 , @base.IPv6.Addr.Byte8, @base.IPv6.Addr.Byte9 , @base.IPv6.Addr.ByteA, @base.IPv6.Addr.ByteB , @base.IPv6.Addr.ByteC, @base.IPv6.Addr.ByteD , @base.IPv6.Addr.ByteE, @base.IPv6.Addr.ByteF ); Shorts = new FixedSizeList <ushort>( @base.IPv6.Addr16.UShort0, @base.IPv6.Addr16.UShort1 , @base.IPv6.Addr16.UShort2, @base.IPv6.Addr16.UShort3 , @base.IPv6.Addr16.UShort4, @base.IPv6.Addr16.UShort5 , @base.IPv6.Addr16.UShort6, @base.IPv6.Addr16.UShort7 ); Ints = new FixedSizeList <uint>( @base.IPv6.Addr32.UInt0, @base.IPv6.Addr32.UInt1 , @base.IPv6.Addr32.UInt2, @base.IPv6.Addr32.UInt3 ); Longs = new FixedSizeList <ulong>( @base.IPv6.Addr64.ULong0, @base.IPv6.Addr64.ULong1 ); }
public static IEnumerable <object[]> Ctor_Object_String_TestData() { foreach (string dataMember in new string[] { null, string.Empty }) { var nonEmptyList = new List <int> { 1, 2, 3 }; yield return(new object[] { nonEmptyList, dataMember, true, false, true, false, false, false, nonEmptyList }); var fixedSizeList = new FixedSizeList <int> { 1, 2, 3 }; yield return(new object[] { fixedSizeList, dataMember, true, false, false, true, false, false, fixedSizeList }); var readOnlyList = new ReadOnlyList <int> { 1, 2, 3 }; yield return(new object[] { readOnlyList, dataMember, false, false, false, false, true, false, readOnlyList }); var synchronizedList = new SynchronizedList <int> { 1, 2, 3 }; yield return(new object[] { synchronizedList, dataMember, true, false, true, false, false, true, synchronizedList }); var nonEmptyArray = new int[] { 1, 2, 3 }; yield return(new object[] { nonEmptyArray, dataMember, true, false, false, true, false, false, nonEmptyArray }); var mockNonEmptyListSource = new Mock <IListSource>(MockBehavior.Strict); mockNonEmptyListSource .Setup(s => s.GetList()) .Returns(nonEmptyList); yield return(new object[] { mockNonEmptyListSource.Object, dataMember, true, false, true, false, false, false, nonEmptyList }); } var list = new List <int> { 1, 2, 3 }; var listDataClass = new DataClass { List = list }; yield return(new object[] { listDataClass, nameof(DataClass.List), true, false, true, false, false, false, list }); yield return(new object[] { listDataClass, nameof(DataClass.List).ToLower(), true, false, true, false, false, false, list }); var mockListSource = new Mock <IListSource>(MockBehavior.Strict); mockListSource .Setup(s => s.GetList()) .Returns(list); var listSourceDataClass = new ListSourceDataClass { ListSource = mockListSource.Object }; yield return(new object[] { listSourceDataClass, nameof(ListSourceDataClass.ListSource), true, false, true, false, false, false, list }); yield return(new object[] { listSourceDataClass, nameof(ListSourceDataClass.ListSource).ToLower(), true, false, true, false, false, false, list }); }
public SummarizedExecutionResult(WorkerId workerId, int workloadCount, Dictionary <string, string> metadata, DFrameControllerOptions options) { this.elapsedValues = new FixedSizeList <TimeSpan>(options.CompleteElapsedBufferCount); this.WorkerId = workerId; this.WorkloadCount = workloadCount; this.ExecutionStatus = ExecutionStatus.Running; this.Metadata = metadata; }
public DQNTrainer(CompiledModel model, int memoryCapacity = 100000) { DiscountFactorGrowSteps = 100000; LearningRateDecaySteps = 500000; ReplayMemory = new FixedSizeList <Tuple <float[], int, float, float[]> >(memoryCapacity, false); TargetModel = model; Reset(); }
/// <summary> /// Initializes a new instance of the <see cref="Instruction"/> class. /// </summary> /// <param name="operandCount">The number of operands for this instruction.</param> protected Instruction(int operandCount) : base() { #region Contract if (operandCount < 0) throw new ArgumentOutOfRangeException("operandCount"); #endregion operands = new FixedSizeList<Operand>(operandCount); }
public CodeWriter(TextWriter destination, FixedSizeList<Schema.Node> nodes, string @namespace, string serializer) { this.destination = destination; this.@namespace = @namespace; this.serializer = serializer; foreach (var node in nodes) { if (node.id != 0) map[node.id] = node; } }
public void TestCreateEmpty() { var fixedList = new FixedSizeList <int>(10); fixedList.Count.Should().Be(0); fixedList.Buffer.Length.Should().Be(10); for (int i = 0; i < fixedList.Count; ++i) { fixedList.Buffer[i].Should().Be(0); } }
/// <summary> /// Initializes a new instance of the <see cref="Instruction"/> class. /// </summary> /// <param name="operandCount">The number of operands for this instruction.</param> protected Instruction(int operandCount) : base() { #region Contract if (operandCount < 0) { throw new ArgumentOutOfRangeException("operandCount"); } #endregion operands = new FixedSizeList <Operand>(operandCount); }
public void TestTryAdd1() { var fixedList = new FixedSizeList <int>(4); fixedList.Count.Should().Be(0); fixedList.TryAdd(4).Should().BeTrue(); fixedList.Count.Should().Be(1); fixedList.Buffer[0].Should().Be(4); for (int i = 1; i < fixedList.Count; ++i) { fixedList.Buffer[i].Should().Be(0); } }
public void TestTryAddTooMany() { var fixedList = new FixedSizeList <int>(3); fixedList.Count.Should().Be(0); fixedList.TryAdd(42).Should().BeTrue(); fixedList.TryAdd(9001).Should().BeTrue(); fixedList.TryAdd(10).Should().BeTrue(); fixedList.TryAdd(1337).Should().BeFalse(); fixedList.Count.Should().Be(3); fixedList.Buffer[0].Should().Be(42); fixedList.Buffer[1].Should().Be(9001); fixedList.Buffer[2].Should().Be(10); }
public SphereMesh(int resolution) { this.Resolution = resolution; numDivisions = Mathf.Max(0, resolution); numVertsPerFace = ((numDivisions + 3) * (numDivisions + 3) - (numDivisions + 3)) / 2; int numVerts = numVertsPerFace * 8 - (numDivisions + 2) * 12 + 6; int numTrisPerFace = (numDivisions + 1) * (numDivisions + 1); vertices = new FixedSizeList <Vector3> (numVerts); triangles = new FixedSizeList <int> (numTrisPerFace * 8 * 3); vertices.AddRange(baseVertices); // Create 12 edges, with n vertices added along them (n = numDivisions) Edge[] edges = new Edge[12]; for (int i = 0; i < vertexPairs.Length; i += 2) { Vector3 startVertex = vertices.items[vertexPairs[i]]; Vector3 endVertex = vertices.items[vertexPairs[i + 1]]; int[] edgeVertexIndices = new int[numDivisions + 2]; edgeVertexIndices[0] = vertexPairs[i]; // Add vertices along edge for (int divisionIndex = 0; divisionIndex < numDivisions; divisionIndex++) { float t = (divisionIndex + 1f) / (numDivisions + 1f); edgeVertexIndices[divisionIndex + 1] = vertices.nextIndex; vertices.Add(Slerp(startVertex, endVertex, t)); } edgeVertexIndices[numDivisions + 1] = vertexPairs[i + 1]; int edgeIndex = i / 2; edges[edgeIndex] = new Edge(edgeVertexIndices); } // Create faces for (int i = 0; i < edgeTriplets.Length; i += 3) { int faceIndex = i / 3; bool reverse = faceIndex >= 4; CreateFace(edges[edgeTriplets[i]], edges[edgeTriplets[i + 1]], edges[edgeTriplets[i + 2]], reverse); } Vertices = vertices.items; Triangles = triangles.items; }
// on complete. public bool TrySetStatus(ExecutionStatus status, Dictionary <WorkloadId, Dictionary <string, string>?>?results) { if (this.ExecutionStatus == ExecutionStatus.Running) { this.ExecuteCompleted = DateTime.UtcNow; this.ExecutionStatus = status; this.Results = results; if (elapsedValues != null) { var array = elapsedValues.ToArray(); Array.Sort(array); elapsedValues = null; if (array.Length > 0) { if (array.Length == 1) { Median = Percentile90 = Percentile95 = array[0]; } else { // Calc Median if (array.Length % 2 == 0) { var i = array.Length / 2; var i2 = i - 1; Median = TimeSpan.FromTicks((array[i].Ticks + array[i2].Ticks) / 2); } else { Median = array[array.Length / 2]; } // Calc percentile Percentile90 = Percentile(array, 0.9); Percentile95 = Percentile(array, 0.95); } } } return(true); } return(false); }
public ReplayerService() { replayerDataModelList = new FixedSizeList <ReplayerDataModel>(REPLAYER_LAST_HANDS_AMOUNT); dataService = ServiceLocator.Current.GetInstance <IDataService>(); playerStatisticRepository = ServiceLocator.Current.GetInstance <IPlayerStatisticRepository>(); }
/** * Returns a fixed-sized list backed by the given list. * Elements may not be added or removed from the returned list, but * existing elements can be changed (for instance, via the * {@link List#set(int,Object)} method). * * @param list the list whose size to fix, must not be null * @return a fixed-size list backed by that list * @throws IllegalArgumentException if the List is null */ public static java.util.List <Object> fixedSizeList(java.util.List <Object> list) { return(FixedSizeList.decorate(list)); }
void CreateFace(Edge sideA, Edge sideB, Edge bottom, bool reverse) { int numPointsInEdge = sideA.vertexIndices.Length; var vertexMap = new FixedSizeList <int> (numVertsPerFace); vertexMap.Add(sideA.vertexIndices[0]); // top of triangle for (int i = 1; i < numPointsInEdge - 1; i++) { // Side A vertex vertexMap.Add(sideA.vertexIndices[i]); // Add vertices between sideA and sideB Vector3 sideAVertex = vertices.items[sideA.vertexIndices[i]]; Vector3 sideBVertex = vertices.items[sideB.vertexIndices[i]]; int numInnerPoints = i - 1; for (int j = 0; j < numInnerPoints; j++) { float t = (j + 1f) / (numInnerPoints + 1f); vertexMap.Add(vertices.nextIndex); vertices.Add(Slerp(sideAVertex, sideBVertex, t)); } // Side B vertex vertexMap.Add(sideB.vertexIndices[i]); } // Add bottom edge vertices for (int i = 0; i < numPointsInEdge; i++) { vertexMap.Add(bottom.vertexIndices[i]); } // Triangulate int numRows = numDivisions + 1; for (int row = 0; row < numRows; row++) { // vertices down left edge follow quadratic sequence: 0, 1, 3, 6, 10, 15... // the nth term can be calculated with: (n^2 - n)/2 int topVertex = ((row + 1) * (row + 1) - row - 1) / 2; int bottomVertex = ((row + 2) * (row + 2) - row - 2) / 2; int numTrianglesInRow = 1 + 2 * row; for (int column = 0; column < numTrianglesInRow; column++) { int v0, v1, v2; if (column % 2 == 0) { v0 = topVertex; v1 = bottomVertex + 1; v2 = bottomVertex; topVertex++; bottomVertex++; } else { v0 = topVertex; v1 = bottomVertex; v2 = topVertex - 1; } triangles.Add(vertexMap.items[v0]); triangles.Add(vertexMap.items[(reverse) ? v2 : v1]); triangles.Add(vertexMap.items[(reverse) ? v1 : v2]); } } }
/// <summary> /// Initializes a new instance of the <see cref="SparkDataConfig"/> class. /// </summary> public SparkDataConfig() { NcoaSettings = new NcoaSettings(); SparkDataApiKey = string.Empty; Messages = new FixedSizeList <string>(30); // Keep last 30 entries }
private static void ConfigureNode(System.Type type, Node node, Dictionary <System.Type, Node> map) { var nestedNodes = new List <Node.NestedNode>(); List <Field> fields = new List <Field>(); if (type.IsEnum) { node.Union = Node.Unions.@enum; var @enum = node.@enum; var list = new List <Enumerant>(); foreach (var field in type.GetFields()) { var fa = (FieldAttribute)Attribute.GetCustomAttribute(field, typeof(FieldAttribute)); if (fa == null) { continue; } list.Add(new Enumerant { codeOrder = checked ((ushort)fa.Number), name = Text.Create(node, field.Name) }); } @enum.enumerants = FixedSizeList <Enumerant> .Create(node, list); } else { node.Union = Node.Unions.@struct; var @struct = node.@struct; @struct.fields = FixedSizeList <Field> .Create(node, fields); @struct.isGroup = Attribute.IsDefined(type, typeof(GroupAttribute)); } var nestedTypes = type.GetNestedTypes(); foreach (var nestedType in nestedTypes) { Node nested; if (map.TryGetValue(nestedType, out nested)) { nestedNodes.Add(new Node.NestedNode { id = nested.id, name = nested.displayName }); } } node.nestedNodes = CapnProto.FixedSizeList <Node.NestedNode> .Create(node, nestedNodes); ushort discCount = 0; uint discOffset = 0; foreach (var field in type.GetFields()) { var member = CreateField(node, field, ref discCount, ref discOffset); if (member.IsValid()) { fields.Add(member); } } foreach (var prop in type.GetProperties()) { var member = CreateField(node, prop, ref discCount, ref discOffset); if (member.IsValid()) { fields.Add(member); } } if (discCount != 0 && node.Union == Node.Unions.@struct) { var @struct = node.@struct; @struct.discriminantCount = discCount; @struct.discriminantOffset = discOffset / 16; } }