本文整理汇总了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));
}
}
示例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;
}
示例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;
}
}
}
示例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]);
}
}
}