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


C# SparseArray.GetSparseIndex方法代码示例

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


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

示例1: IterationStarting

 public void IterationStarting(int iteration)
 {
     // initialize data structures
     HouseholdsByPD = ZoneSystemHelper.CreatePDArray<PDData>(Root.ZoneSystem.ZoneArray);
     var flat = HouseholdsByPD.GetFlatData();
     for(int i = 0; i < flat.Length; i++)
     {
         flat[i] = new PDData(HouseholdsByPD.GetSparseIndex(i));
     }
 }
开发者ID:Cocotus,项目名称:XTMF,代码行数:10,代码来源:TTSPopulationReplicationForcast.cs

示例2: CheckForOverlap

 private bool CheckForOverlap(ref string error, SparseArray<Range> sparseArray)
 {
     var flatData = sparseArray.GetFlatData();
     for ( int i = 0; i < flatData.Length; i++ )
     {
         for ( int j = i + 1; j < flatData.Length; j++ )
         {
             if ( flatData[i].Start < flatData[j].Start )
             {
                 if ( flatData[i].Stop >= flatData[j].Start )
                 {
                     error = "In '" + this.Name + "' there is an overlap in age category '" + sparseArray.GetSparseIndex( i )
                         + "' and '" + sparseArray.GetSparseIndex( j );
                     return true;
                 }
             }
             else
             {
                 if ( flatData[j].Stop >= flatData[i].Start )
                 {
                     error = "In '" + this.Name + "' there is an overlap in age category '" + sparseArray.GetSparseIndex( i )
                         + "' and '" + sparseArray.GetSparseIndex( j );
                     return true;
                 }
             }
         }
     }
     return false;
 }
开发者ID:Cocotus,项目名称:XTMF,代码行数:29,代码来源:AggregatedDemographicsData2.cs

示例3: FillRatioIntraZonalTravelTime

 private void FillRatioIntraZonalTravelTime(int districtNumber, IZone[] flatZones, SparseTwinIndex<float> matrix, SparseArray<float> radius)
 {
     var validDistricts = radius.ValidIndexArray();
     var flatRadius = radius.GetFlatData();
     for ( int otherDistrict = 0; otherDistrict < validDistricts.Length; otherDistrict++ )
     {
         var sparseOther = radius.GetSparseIndex( otherDistrict );
         if ( sparseOther == districtNumber ) continue;
         if ( this.AnyTripIntraDistrict( otherDistrict, flatZones, matrix ) )
         {
             var distanceRatio = radius[districtNumber] / flatRadius[otherDistrict];
             var data = matrix.GetFlatData();
             var averageTT = GetAverageIntraDistrictNonIntraZonalTravelTime( sparseOther, flatZones, data );
             var averageIntraZonealTT = GetAverageIntraZonalTravelTime( sparseOther, flatZones, data );
             var zoneRatio = GetNumberOfZonesRatio( flatZones, districtNumber, sparseOther );
             averageTT *= distanceRatio * zoneRatio;
             averageIntraZonealTT *= distanceRatio * zoneRatio;
             for ( int i = 0; i < flatZones.Length; i++ )
             {
                 if ( flatZones[i].PlanningDistrict != districtNumber ) continue;
                 for ( int j = 0; j < flatZones.Length; j++ )
                 {
                     if ( flatZones[j].PlanningDistrict != districtNumber ) continue;
                     if ( i == j )
                     {
                         data[i][j] = averageIntraZonealTT;
                     }
                     else
                     {
                         data[i][j] = averageTT;
                     }
                 }
             }
             break;
         }
     }
 }
开发者ID:Cocotus,项目名称:XTMF,代码行数:37,代码来源:BuildTripMatrix.cs

示例4: WriteAttractionFile

 private void WriteAttractionFile(SparseArray<float> attractions)
 {
     if(!AttractionFileName.ContainsFileName())
     {
         return;
     }
     var flatAttractions = attractions.GetFlatData();
     bool first = !File.Exists(AttractionFileName.GetFileName());
     StringBuilder buildInside = new StringBuilder();
     buildInside.Append(',');
     buildInside.Append(AgeCategoryRange.ToString());
     buildInside.Append(',');
     buildInside.Append(EmploymentStatusCategory.ToString());
     buildInside.Append(',');
     buildInside.Append(OccupationCategory.ToString());
     buildInside.Append(',');
     buildInside.Append(Mobility.ToString());
     buildInside.Append(',');
     string categoryData = buildInside.ToString();
     using (StreamWriter writer = new StreamWriter(AttractionFileName.GetFileName(), true))
     {
         if(first)
         {
             // if we are the first thing to generate, then write the header as well
             writer.WriteLine("Zone,Age,Employment,Occupation,Mobility,Attraction");
         }
         for(int i = 0; i < flatAttractions.Length; i++)
         {
             writer.Write(attractions.GetSparseIndex(i));
             writer.Write(categoryData);
             writer.WriteLine(flatAttractions[i]);
         }
     }
 }
开发者ID:dianatle,项目名称:XTMF,代码行数:34,代码来源:PoRPoWGeneration.cs


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