当前位置: 首页>>代码示例>>C#>>正文


C# HashSet.CopyTo方法代码示例

本文整理汇总了C#中HashSet.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# HashSet.CopyTo方法的具体用法?C# HashSet.CopyTo怎么用?C# HashSet.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HashSet的用法示例。


在下文中一共展示了HashSet.CopyTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderScene

        public OutputData RenderScene(Scene scene)
        {
            ISet<Task<RenderData>> results = new HashSet<Task<RenderData>>();
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    Vector3f rayDirection = renderManager.CalculateEyeRayDirection(x, y);
                    Vector3f rayStart = new Vector3f(x, y, 0.0f);

                    results.Add(taskFactory.StartNew(() => CastEyeRay(new Ray(rayStart, rayDirection), scene)));
                }
            }
            Task<RenderData>[] resultsArray = new Task<RenderData>[results.Count];
            results.CopyTo(resultsArray, 0);

            Task.WaitAll(resultsArray);

            BasicOutputConverter coverter = new BasicOutputConverter(1, width, height);

            RenderData[] finalData = new RenderData[resultsArray.Length];

            for (int i = 0; i < finalData.Length; i++)
            {
                finalData[i] = resultsArray[i].Result;
            }

            return coverter.DoConversion(finalData);
        }
开发者ID:Spaceman1701,项目名称:BetterRayTracer,代码行数:29,代码来源:Renderer.cs

示例2: Add

    private List<Line> lines = new List<Line>(); // The lines contain info about all blocks from bottom to top.

    #endregion Fields

    #region Methods

    /// <summary>
    /// Add the chip blocks to grid.
    /// </summary>
    /// <param name='toAdd'>
    /// The chip is will be added.
    /// </param>
    public void Add(Chip toAdd)
    {
        int lineIndex, blockIndex;
        Vector3 blockPos;
        Line tempLine;
        HashSet<Line> affectedLines=new HashSet<Line>();
        foreach(Transform blockTrans in toAdd.blocks){
            blockPos=transform.TransformPoint(blockTrans.position);
            lineIndex=Mathf.RoundToInt(blockPos.y);
            if(lineIndex>=lines.Count){
                for(int i=lineIndex-lines.Count; i>=0; i--){
                    tempLine=Instantiate(lineEtalon)as Line;
                    tempLine.transform.SetParent(transform);
                    tempLine.transform.rotation=Quaternion.identity;
                    tempLine.transform.localPosition=new Vector3(0f, lines.Count, 0f);
                    lines.Add(tempLine);
                }
            }
            tempLine=lines[lineIndex];
            affectedLines.Add(tempLine);

            blockIndex=Mathf.RoundToInt(blockPos.x);
            tempLine.blocks[blockIndex]=blockTrans;
            blockTrans.SetParent(tempLine.transform);
        }
        //remove chip
        toAdd.blocks.Clear();
        Destroy(toAdd.gameObject);
        //check lines for remove
        Line[] checkList=new Line[affectedLines.Count];
        affectedLines.CopyTo(checkList);
        RemoveFilledLines(checkList);
    }
开发者ID:Multirez,项目名称:TetrisTest,代码行数:45,代码来源:Grid.cs

示例3: Intersection

    public int[] Intersection(int[] nums1, int[] nums2)
    {
        int[] intersectArray = new int[0];

        if (nums1.Length == 0 || nums2.Length == 0)
        {
            return intersectArray;
        }

        foreach(int i in nums1)
        {
            if (!valueSet.Contains(i))
            {
                valueSet.Add(i);
            }
        }

        HashSet<int> intersectSet = new HashSet<int>();
        foreach(int j in nums2)
        {
            if (valueSet.Contains(j))
            {
                intersectSet.Add(j);
            }
        }

        intersectArray = new int[intersectSet.Count];
        intersectSet.CopyTo(intersectArray);
        return intersectArray;
    }
开发者ID:hsn6,项目名称:training,代码行数:30,代码来源:LeetCode_IntersectArray.cs

示例4: GetAuditSaveRequest

        protected AuditSaveRequest GetAuditSaveRequest(ISaveRequestHandler handler)
        {
            var auditFields = new HashSet<Field>();
            var flag = handler.IsCreate ? FieldFlags.Insertable : FieldFlags.Updatable;
            foreach (var field in handler.Row.GetFields())
                if (field.Flags.HasFlag(flag))
                    auditFields.Add(field);

            Field[] array = new Field[auditFields.Count];
            auditFields.CopyTo(array);

            var auditRequest = new AuditSaveRequest(handler.Row.Table, (IIdRow)handler.Old, (IIdRow)handler.Row, array);

            var parentIdRow = handler.Row as IParentIdRow;
            if (parentIdRow != null)
            {
                var parentIdField = (Field)parentIdRow.ParentIdField;

                if (!parentIdField.ForeignTable.IsTrimmedEmpty())
                {
                    auditRequest.ParentTypeId = parentIdField.ForeignTable;
                    auditRequest.OldParentId = handler.IsCreate ? null : parentIdRow.ParentIdField[handler.Old];
                    auditRequest.NewParentId = parentIdRow.ParentIdField[handler.Row];
                }
            }

            return auditRequest;
        }
开发者ID:volkanceylan,项目名称:Serenity,代码行数:28,代码来源:AuditLogBehavior.cs

示例5: ForceDirectedLayout

        /// <summary>
        /// Initializes this force-directed layout. Assumes that graph has some
        /// reasonable initial node positions.
        /// </summary>
        /// <param name="graph">The graph to layout.</param>
        /// <param name="start_node">The node to start layout from.</param>
        public ForceDirectedLayout(IReadOnlyGraph<FDLNode, FDLEdge> graph, FDLNode start_node)
        {
            if (graph == null)
                throw new ArgumentNullException("graph");
            if (start_node == null)
                throw new ArgumentNullException("start_node");
            if (!graph.ContainsNode(start_node))
                throw new ArgumentException("start_node must be in this graph");

            //initialize nodes array to only the reachable nodes
            ArrayList n = new ArrayList(graph.NodeCount);
            Algorithms.Algorithms.BreadthFirstSearch(graph, start_node, null, delegate(FDLNode node){
                n.Add(node);
            });
            nodes = new FDLNode[n.Count];
            n.CopyTo(nodes);

            new_positions = new MutablePoint[nodes.Length];
            accels = new double[nodes.Length];

            //summarize constraints
            HashSet<FDLEdge> h = new HashSet<FDLEdge>();
            for (int i = 0; i < nodes.Length; i++)
            {
                foreach (FDLEdge edge in nodes[i].OutEdges)
                {
                    DefaultEdge reverse = edge.Target.GetEdgeTo(edge.Source);
                    if(h.Contains(edge) || (reverse != null && h.Contains(reverse)))
                        continue;
                    h.Add(edge);
                }
            }
            constraints = new FDLEdge[h.Count];
            h.CopyTo(constraints);
        }
开发者ID:sooniln,项目名称:angle_constrained_fdl,代码行数:41,代码来源:ForceDirectedLayout.cs

示例6: RemoveDuplicates

 public static string[] RemoveDuplicates(string[] s)
 {
     HashSet<string> set = new HashSet<string>(s);
     string[] result = new string[set.Count];
     set.CopyTo(result);
     return result;
 }
开发者ID:kaungs542,项目名称:appraisal-mp15,代码行数:7,代码来源:ImportExportStaffList.aspx.cs

示例7: Union

        public IGeometry Union()
        {
            PointLocator locater = new PointLocator();
            // use a set to eliminate duplicates, as required for union
            var exteriorCoords = new HashSet<Coordinate>();

            foreach (IPoint point in PointExtracter.GetPoints(_pointGeom))
            {
                Coordinate coord = point.Coordinate;
                Location loc = locater.Locate(coord, _otherGeom);

                if (loc == Location.Exterior)
                {
                    exteriorCoords.Add(coord);
                }
            }

            // if no points are in exterior, return the other geom
            if (exteriorCoords.Count == 0)
            {
                return _otherGeom;
            }

            // make a puntal geometry of appropriate size
            var exteriorCoordsArray = new Coordinate[exteriorCoords.Count];
            exteriorCoords.CopyTo(exteriorCoordsArray, 0);
            Array.Sort(exteriorCoordsArray);
            ICoordinateSequence coords = _geomFact.CoordinateSequenceFactory.Create(exteriorCoordsArray);
            IGeometry ptComp = coords.Count == 1 ? (IGeometry)_geomFact.CreatePoint(coords.GetCoordinate(0)) : _geomFact.CreateMultiPoint(coords);

            // add point component to the other geometry
            return GeometryCombiner.Combine(ptComp, _otherGeom);
        }
开发者ID:jaundice,项目名称:NetTopologySuite,代码行数:33,代码来源:PointGeometryUnion.cs

示例8: foreach

        void IInitializable.Initialize()
        {

            // parse resource metadata annotation.

            HashSet<string> metafileExts = new HashSet<string>();            
            char[] sep = { ';' };
            foreach (ChildInfo chInfo in m_schemaLoader.GetRootElements())
            {
                DomNodeType domtype = chInfo.Type;
                IEnumerable<XmlNode> annotations = domtype.GetTag<IEnumerable<XmlNode>>();
                if (annotations == null)
                    continue;
                
                foreach (XmlElement annot in annotations)
                {
                    if (annot.LocalName != "ResourceMetadata")
                        continue;

                    string metaExt = annot.GetAttribute("metadataFileExt").ToLower();
                    metafileExts.Add(metaExt);
                    string[] resExts = annot.GetAttribute("resourceFileExts").ToLower().Split(sep, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string ext in resExts)
                    {
                        ResourceMetadataInfo metadataInfo
                            = new ResourceMetadataInfo(chInfo, metaExt);
                        m_extMap.Add(ext, metadataInfo);
                    }                    
                }                
            }
            m_metadataFileExts = new string[metafileExts.Count];
            metafileExts.CopyTo(m_metadataFileExts);
            
        }
开发者ID:BeRo1985,项目名称:LevelEditor,代码行数:34,代码来源:ResourceMetadataService.cs

示例9: Init

        public static void Init()
        {
            if ( !PluginSettings.Instance.PlayerBlockEnforcementEnabled )
                return;

            if (_init)
                return;

            _init = true;

            MyEntities.OnEntityAdd += MyEntities_OnEntityAdd;

            HashSet<MyEntity> allEntities = new HashSet<MyEntity>();
            Wrapper.GameAction( () => allEntities = MyEntities.GetEntities() );

            MyEntity[] entitiesCopy = new MyEntity[allEntities.Count];
            allEntities.CopyTo( entitiesCopy );

            Parallel.ForEach( entitiesCopy, ( entity ) =>
                                            {
                                                var grid = entity as MyCubeGrid;
                                                if ( grid == null )
                                                    return;

                                                InitGrid( grid );
                                            } );
            Essentials.Log.Info( "Initialized player block enforcement." );
            ProcessEnforcement();
        }
开发者ID:rexxar-tc,项目名称:EssentialsPlugin,代码行数:29,代码来源:PlayerBlockEnforcement.cs

示例10: Filter

 protected virtual void Filter(HashSet<Tile> tiles)
 {
     Tile[] array = new Tile[tiles.Count];
     tiles.CopyTo(array);
     for (int i = array.Length - 1; i >= 0; --i)
         if (array[i].unit != null)
             tiles.Remove(array[i]);
 }
开发者ID:Policenaut,项目名称:Unity-SRPG,代码行数:8,代码来源:Movement.cs

示例11: Test_CopyTo

 public void Test_CopyTo()
 {
     hs = new HashSet<int>();
     hs.Add(1); hs.Add(2); hs.Add(3);
     int[] mass = { 1, 2, 3 };
     int[] mass1 = new int[3];
     hs.CopyTo(mass1);
     Assert.That(mass1, Is.EqualTo(mass));
 }
开发者ID:Banych,项目名称:HashSet-T--class,代码行数:9,代码来源:Program.cs

示例12: CopyTo_Array_Test2

        public static void CopyTo_Array_Test2()
        {
            HashSet<int> hashSet = new HashSet<int>(new int[] { 1, 2, 3, 4, 5, 6, 7 });
            int[] array = new int[] { -1, -2, -3, -4, -5, -6, -7, -8, -9 };
            hashSet.CopyTo(array);
            HashSet<int> hashSet2 = new HashSet<int>(array);

            HashSetTestSupport<int>.VerifyHashSet(hashSet, new int[] { 1, 2, 3, 4, 5, 6, 7 }, EqualityComparer<int>.Default);
            HashSetTestSupport<int>.VerifyHashSet(hashSet2, new int[] { 1, 2, 3, 4, 5, 6, 7, -8, -9 }, EqualityComparer<int>.Default);
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:10,代码来源:HashSet_CopyToTests.cs

示例13: ReadBeats

 private uint[] ReadBeats(StoryBeat[] beats)
 {
     HashSet<uint> seenIds = new HashSet<uint>();
     foreach (StoryBeat beat in beats)
         foreach (StoryEvent evt in beat.Events)
             foreach (uint id in evt.Participants)
                 seenIds.Add(id);
     uint[] result = new uint[seenIds.Count];
     seenIds.CopyTo(result);
     return result;
 }
开发者ID:fgeraci,项目名称:CS195-Core,代码行数:11,代码来源:StoryArc.cs

示例14: CopyTo_Array_Exceptions

        public static void CopyTo_Array_Exceptions()
        {
            //Test 1: Array is null
            HashSet<int> hashSet = new HashSet<int>(new int[] { 1, 2, 3, 4, 5, 6, 7 });
            int[] array = null;
            Assert.Throws<ArgumentNullException>(() => hashSet.CopyTo(array)); //"Expected ArgumentNullException"

            //Test 2: Array is one smaller than set size
            hashSet = new HashSet<int>(new int[] { 1, 2, 3, 4, 5, 6, 7 });
            array = new int[6];
            Assert.Throws<ArgumentException>(() => hashSet.CopyTo(array)); //"Expected ArgumentException"
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:12,代码来源:HashSet_CopyToTests.cs

示例15: setIntTuplesWithSwapsAndSignChange

 public void setIntTuplesWithSwapsAndSignChange(IntTuple[] inputIntTuples, IntTupleEqualityComparer comparer)
 {
     HashSet<IntTuple> container = new HashSet<IntTuple>(comparer);
     foreach (var intTuple in inputIntTuples)
     {
         container.Add(intTuple);
         addOppositeElements(container, intTuple);
         addSwapElements(container);
     }
     this.intTuples = new IntTuple[container.Count];
     container.CopyTo(this.intTuples);
 }
开发者ID:szalaigj,项目名称:TilingApplication,代码行数:12,代码来源:Shell.cs


注:本文中的HashSet.CopyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。