コード例 #1
0
    /// <summary>
    /// Sets the chunk data.
    /// </summary>
    /// <param name="x">The x coordinate.</param>
    /// <param name="z">The z coordinate.</param>
    /// <param name="terrainData">Terrain data.</param>
    public void SetChunkData(int x, int y, int z, CubicTerrainData terrainData)
    {
        lock (this.chunkDataLockObject)
        {
            BufferedStream  chunkDataStream = new BufferedStream(File.Open(this.chunkDataFile, FileMode.Open));
            ListIndex <int> index           = new ListIndex <int>(x, y, z);

            long position = chunkDataStream.Length;
            if (this.chunkLookupTable.ContainsKey(x, y, z))
            {
                // Key already available
                position = this.chunkLookupTable[index];
            }
            else
            {
                // Key not available
                // Update lookup table
                this.chunkLookupTable.Add(x, y, z, chunkDataStream.Length);
                this.WriteLookupTable(x, y, z, chunkDataStream.Length);
            }

            // Write chunk data
            chunkDataStream.Position = position;
            terrainData.SerializeChunk(chunkDataStream);

            chunkDataStream.Flush();
            chunkDataStream.Close();
        }
    }
コード例 #2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Accelerators.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ (BackColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ForeColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ Items.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ ListIndex.GetHashCode();
         hashCode = (hashCode * 397) ^ MajorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ MinorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ (MouseIcon?.Length.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ MousePointer.GetHashCode();
         hashCode = (hashCode * 397) ^ PropMask.GetHashCode();
         hashCode = (hashCode * 397) ^ Remainder.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ Size.GetHashCode();
         hashCode = (hashCode * 397) ^ TabData.GetHashCode();
         hashCode = (hashCode * 397) ^ TabFixedHeight.GetHashCode();
         hashCode = (hashCode * 397) ^ TabFixedWidth.GetHashCode();
         hashCode = (hashCode * 397) ^ TabNames.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ TabOrientation.GetHashCode();
         hashCode = (hashCode * 397) ^ TabsAllocated.GetHashCode();
         hashCode = (hashCode * 397) ^ TabStyle.GetHashCode();
         hashCode = (hashCode * 397) ^ Tags.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ TextProps.GetHashCode();
         hashCode = (hashCode * 397) ^ TipStrings.Length.GetHashCode();
         hashCode = (hashCode * 397) ^ VariousPropertyBits.GetHashCode();
         return(hashCode);
     }
 }
コード例 #3
0
        public ConfigurationNodeCollection()
        {
            _listIndex = new ListIndex <ConfigurationNode>("List");
            _nameIndex = new UniqueIndex <string, ConfigurationNode>("Name", node => GetKeyResponse.Create(true, node.Name), SortOrder.Ascending);

            _collection = new IndexableCollection <ConfigurationNode>(_listIndex);
            _collection.Indexes.Add(_nameIndex);
        }
コード例 #4
0
ファイル: Parser.cs プロジェクト: BetoVas97/chimera
        //this method has the structure for an expression with brackets List
        public void auxiliarMethod(Node result)
        {
            var ListIndex = new ListIndex();

            ListIndex.AnchorToken = Expect(TokenCategory.BRACKET_OPEN);
            ListIndex.Add(Expression());
            result.Add(ListIndex);
            Expect(TokenCategory.BRACKET_CLOSE);
        }
コード例 #5
0
ファイル: List3D.cs プロジェクト: wty0512/cubicworld
    /// <summary>
    /// Add the specified data at the position of x, y, z.
    /// </summary>
    /// <param name="x">The x coordinate.</param>
    /// <param name="y">The y coordinate.</param>
    /// <param name="z">The z coordinate.</param>
    /// <param name="data">Data.</param>
    public void Add(int x, int y, int z, T data)
    {
        ListIndex <int> indexObject = new ListIndex <int> (x, y, z);

        if (!this.listData.ContainsKey(indexObject))
        {
            this.listData.Add(indexObject, data);
        }
    }
コード例 #6
0
        public async Task Reindexer()
        {
            var parameters = new Reindexer.Parameters {
                BatchSize                    = 10,
                WaitBetweenBatches           = TimeSpan.FromMilliseconds(0),
                WaitBetweenChecksForNewItems = TimeSpan.FromMilliseconds(0)
            };

            var itemsSemaphore = new SemaphoreSlim(1);
            var items          = new List <ISearchIndexItemWithTime>();
            var index          = new ListIndex();

            var reindexer = new Reindexer(
                index,
                async(since, skip, maxCount) =>
            {
                try
                {
                    await itemsSemaphore.WaitAsync();
                    return(items
                           .OrderBy(item => item.LastUpdated)
                           .Where(item => item.LastUpdated > since)
                           .Skip(skip)
                           .Take(maxCount.Value)
                           .ToArray());
                }
                finally
                {
                    itemsSemaphore.Release();
                }
            },
                parameters);

            var tscs = Enumerable.Range(0, 4).Select(_ => new TaskCompletionSource <bool>()).ToArray();
            var c    = 0;

            reindexer.OnSuccessfulUpdate += (s, a) =>
            {
                tscs[c].SetResult(true);
                c++;
            };

            await itemsSemaphore.WaitAsync();

            await reindexer.Start(new DateTime(), 0);

            items.AddRange(MakeItems(DateTime.Now - TimeSpan.FromDays(1), 40));
            itemsSemaphore.Release();
            await tscs[0].Task;

            var indexItems = index.Items.OrderBy(i => i.Ref, StringComparer.Ordinal).ToArray();

            Assert.Equal(items.OrderBy(i => i.LastUpdated).Take(indexItems.Length).OrderBy(i => i.Ref, StringComparer.Ordinal), indexItems);

            await itemsSemaphore.WaitAsync();
        }
コード例 #7
0
 /// <summary>
 ///
 /// </summary>
 public TextDataSetTableCollection()
 {
     _listIndex = new ListIndex <TextDataSetTable>("List");
     _nameIndex = new UniqueIndex <string, TextDataSetTable>(
         "Name",
         item => GetKeyResponse.Create(true, item.Name),
         SortOrder.None);
     _collection = new IndexableCollection <TextDataSetTable>(_listIndex);
     _collection.Indexes.Add(_nameIndex);
 }
コード例 #8
0
    /// <summary>
    ///
    /// </summary>
    public TextDataParameterCollection()
    {
        _listIndex = new ListIndex <TextDataParameter>("List");
        _nameIndex = new UniqueIndex <string, TextDataParameter>(
            "Name",
            parameter => GetKeyResponse.Create(true, parameter.ParameterName),
            SortOrder.None);

        _collection = new IndexableCollection <TextDataParameter>(_listIndex);
        _collection.Indexes.Add(_nameIndex);
    }
コード例 #9
0
    public TextDataColumnCollection()
    {
        _listIndex = new ListIndex <TextDataColumn>("List");

        _nameIndex = new UniqueIndex <string, TextDataColumn>(
            "Name",
            column => GetKeyResponse.Create(true, column.ColumnName),
            SortOrder.None);

        _collection = new IndexableCollection <TextDataColumn>(_listIndex);
    }
コード例 #10
0
        /// <summary>
        ///
        /// </summary>
        public ConfigurationAttributeCollection()
        {
            _listIndex = new ListIndex <ConfigurationAttribute>("List");

            _nameIndex = new UniqueIndex <string, ConfigurationAttribute>(
                "NameIndex",
                attribute => GetKeyResponse.Create(true, attribute.Name),
                SortOrder.None);

            _collection = new IndexableCollection <ConfigurationAttribute>(_listIndex);
            _collection.Indexes.Add(_nameIndex);
        }
コード例 #11
0
        public string Play(ListIndex index)
        {
            if (squareCollection[index] != Square.Empty)
            {
                var pos = index.ToBoardRowColumn();
                throw new PostionAlreadyPlayedException($"Cannot play position {pos.Row}, {pos.Column} because it was already full");
            }
            var nextSquare = NextSquare();

            squareCollection[index] = nextSquare;
            winner = EvaluateWinner();
            return(nextSquare.Value);
        }
コード例 #12
0
 private void SelectionChanged(object sender, RoutedEventArgs e)
 {
     /*
      * Message to emit
      */
     System.Diagnostics.Debug.WriteLine("In selection");
     //send a message to the view controler to set the selected index
     if (cutList.SelectedIndex != -1)
     {
         ListIndex listIndex = new ListIndex();
         listIndex.setValue(cutList.SelectedIndex);
         Messenger.Default.Send(listIndex);
     }
 }
コード例 #13
0
ファイル: Parser.cs プロジェクト: BetoVas97/chimera
        public Node ListAssignmentS()
        {
            var result = new ListAssignmentS();

            Expect(TokenCategory.BRACKET_OPEN);
            var list = new ListIndex();

            list.Add(Expression());
            result.Add(list);
            Expect(TokenCategory.BRACKET_CLOSE);

            Expect(TokenCategory.ASSIGN);
            result.Add(Expression());
            Expect(TokenCategory.SEMICOLON);
            return(result);
        }
コード例 #14
0
        private void PlayLayout(string[] plays)
        {
            var moveList      = plays.Select((play, index) => new { ChipType = ToChipType(play), index = index });
            var xMoveList     = moveList.Where(x => x.ChipType == ChipTypes.X).ToList();
            var oPositionList = moveList.Where(x => x.ChipType == ChipTypes.O).ToList();

            for (int i = 0; i < xMoveList.Count; i++)
            {
                var currentX = ListIndex.Create(xMoveList[i].index);
                board.Play(currentX);
                if (i < oPositionList.Count)
                {
                    var currentO = ListIndex.Create(oPositionList[i].index);
                    board.Play(currentO);
                }
            }
            UpdateStatus();
        }
コード例 #15
0
        private static void Merge(List <int>[][] lists, ListIndex iIndex, ListIndex adjNodeIndex)
        {
            if (iIndex.J == 1)
            {
                foreach (int num in lists[adjNodeIndex.I][adjNodeIndex.J])
                {
                    lists[iIndex.I][0].Add(num);
                }
            }
            else
            {
                foreach (int num in lists[adjNodeIndex.I][adjNodeIndex.J])
                {
                    lists[iIndex.I][1].Add(num);
                }
            }

            lists[adjNodeIndex.I][adjNodeIndex.J].Clear();
        }
コード例 #16
0
        private void SetSelectedRow(ListIndex li)
        {
            selectedRow      = li.getValue();
            RefreshButton    = true;
            BackgroundButton = true;
            //chargement des databases
            if (selectedRow != -1)
            {
                var thumb = Cuts.GetAt(selectedRow).Thumbnail;
                TeamOne   = Cuts.GetAt(selectedRow).Thumbnail.TeamOne;
                TeamTwo   = Cuts.GetAt(selectedRow).Thumbnail.TeamTwo;
                DbCharOne = Cuts.GetAt(selectedRow).Thumbnail.TeamOne.DataBase;
                DbCharTwo = Cuts.GetAt(selectedRow).Thumbnail.TeamTwo.DataBase;
                Debug.WriteLine(Cuts.GetAt(selectedRow).Thumbnail.TeamOne.DataBase[0].Name);
                Debug.WriteLine(Cuts.GetAt(selectedRow).Thumbnail.TeamOne.DataBase[0].IsPlayed);

                Background = new BitmapImage(thumb.Background);
                ResetPreview();
            }
        }
コード例 #17
0
    /// <summary>
    /// Sets the chunk data.
    /// </summary>
    /// <param name="x">The x coordinate.</param>
    /// <param name="z">The z coordinate.</param>
    /// <param name="terrainData">Terrain data.</param>
    public void SetChunkData(int x, int y, int z, CubicTerrainData terrainData)
    {
        lock (this.chunkDataLockObject)
        {
            BufferedStream chunkDataStream = new BufferedStream (File.Open (this.chunkDataFile, FileMode.Open));
            ListIndex<int> index = new ListIndex<int>(x,y,z);

            long position = chunkDataStream.Length;
            if (this.chunkLookupTable.ContainsKey(x,y,z))
            {
                // Key already available
                position = this.chunkLookupTable[index];
            }
            else
            {
                // Key not available
                // Update lookup table
                this.chunkLookupTable.Add (x,y,z, chunkDataStream.Length);
                this.WriteLookupTable (x,y,z, chunkDataStream.Length);
            }

            // Write chunk data
            chunkDataStream.Position = position;
            terrainData.SerializeChunk (chunkDataStream);

            chunkDataStream.Flush ();
            chunkDataStream.Close ();
        }
    }
コード例 #18
0
 private void SetSelectedRow(ListIndex li)
 {
     selectedRow = li.getValue();
     BeginEnable = true;
     EndEnable   = true;
 }
コード例 #19
0
 private void SetSelectedRow(ListIndex li)
 {
     selectedRow = li.getValue();
     DelEnable   = true;
 }
コード例 #20
0
 public override string ToString()
 {
     return(ListIndex.ToString() + ":" + StringIndex);
 }
コード例 #21
0
 public Square this [ListIndex i]
 {
     get => itemList[i.Value];
コード例 #22
0
ファイル: List3D.cs プロジェクト: wty0512/cubicworld
    /// <summary>
    /// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="List3D`1+ListIndex`1"/>.
    /// </summary>
    /// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="List3D`1+ListIndex`1"/>.</param>
    /// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current
    /// <see cref="List3D`1+ListIndex`1"/>; otherwise, <c>false</c>.</returns>
    public override bool Equals(object obj)
    {
        ListIndex <T> other = obj as ListIndex <T>;

        return(this.x.Equals(other.x) && this.y.Equals(other.y) && this.z.Equals(other.z));
    }
コード例 #23
0
        public Type Visit(ListIndex node)
        {
            var index = Visit((dynamic)node[0]);

            return(index);
        }
コード例 #24
0
ファイル: List3D.cs プロジェクト: wty0512/cubicworld
 public T this[ListIndex <int> index]
 {
     get { return(this.listData[index]); }
 }
コード例 #25
0
ファイル: PyList.cs プロジェクト: kskhsn/PyList
 public PyList <T> this[int start, ListIndex end]
 {
     get { return(new PyList <T>(this.list.Skip(this.CalcIndexSafe(start)))); }
     set { this[start, this.list.Count] = value; }
 }
コード例 #26
0
ファイル: List3D.cs プロジェクト: wty0512/cubicworld
 /// <summary>
 /// Remove the specified index.
 /// </summary>
 /// <param name="index">Index.</param>
 public void Remove(ListIndex <int> index)
 {
     this.listData.Remove(index);
 }
コード例 #27
0
        public static bool IsBipartite(int[][] graph)
        {
            List <int>[][] lists = new List <int> [50][];

            for (int i = 0; i < lists.Length; i++)
            {
                lists[i] = new List <int>[2] {
                    new List <int>(), new List <int>()
                }
            }
            ;

            int availableIndex = 0;

            for (int i = 0; i < graph.Length; i++)
            {
                for (int j = 0; j < graph[i].Length; j++)
                {
                    int adjNode = graph[i][j];

                    if (adjNode > i)
                    {
                        ListIndex iIndex       = Find(lists, i);
                        ListIndex adjNodeIndex = Find(lists, adjNode);

                        if (iIndex.I == -1 && adjNodeIndex.I == -1)
                        {
                            lists[availableIndex][0] = new List <int>()
                            {
                                i
                            };
                            lists[availableIndex++][1] = new List <int>()
                            {
                                adjNode
                            };
                        }
                        else if (adjNodeIndex.I == -1)
                        {
                            if (iIndex.J == 1)
                            {
                                lists[iIndex.I][0].Add(adjNode);
                            }
                            else
                            {
                                lists[iIndex.I][1].Add(adjNode);
                            }
                        }
                        else if (iIndex.I == -1)
                        {
                            if (adjNodeIndex.J == 1)
                            {
                                lists[adjNodeIndex.I][0].Add(i);
                            }
                            else
                            {
                                lists[adjNodeIndex.I][1].Add(i);
                            }
                        }
                        else
                        {
                            if (iIndex.I == adjNodeIndex.I && iIndex.J == adjNodeIndex.J)
                            {
                                return(false);
                            }
                            else if (iIndex.I != adjNodeIndex.I)
                            {
                                Merge(lists, iIndex, adjNodeIndex);
                            }
                        }
                    }
                }
            }

            return(true);
        }
コード例 #28
0
ファイル: PyList.cs プロジェクト: kskhsn/PyList
 public PyList <T> this[ListIndex start, int end]
 {
     get { return(new PyList <T>(this.list.Take(this.CalcIndexSafe(end)))); }
     set { this[0, end] = value; }
 }