Beispiel #1
0
		static void PartSort( uint Start, uint ItemCount, SphereEntry[] SortBuffer )
		{
			uint i, FirstPartCount, SecondPartCount, FirstPartStart, SecondPartStart, EndPart;
			if( ItemCount <= 1 )
			{
				return;
			}
			SecondPartCount = ItemCount / 2;
			FirstPartCount = ItemCount - SecondPartCount;
			FirstPartStart = Start;
			SecondPartStart = Start + FirstPartCount;
			EndPart = FirstPartStart + ItemCount;

			// Sort subtables

			PartSort( FirstPartStart, FirstPartCount, SortBuffer );
			PartSort( SecondPartStart, SecondPartCount, SortBuffer );

			// Copy first partition into buffer

			for( i = Start; i < SecondPartStart; i++ )
			{
				SortBuffer[i] = SectorList[i];
			}

			// Make partition fusion

			for( i = Start; i < EndPart; i++ )
			{
				if( FirstPartCount > 0 && SecondPartCount > 0 )
				{
					if( SortBuffer[FirstPartStart].SectorDistance <= SectorList[SecondPartStart].SectorDistance ) { SectorList[i] = SortBuffer[FirstPartStart++]; FirstPartCount--; }
					else { SectorList[i] = SectorList[SecondPartStart++]; SecondPartCount--; }
				}
				else
				{
					if( FirstPartCount != 0 ) { SectorList[i] = SortBuffer[FirstPartStart++]; FirstPartCount--; }
					else { SectorList[i] = SectorList[SecondPartStart++]; SecondPartCount--; }
				}
			}
		}
Beispiel #2
0
		static void Sort()
		{
			SphereEntry[] SortBuffer;
			SortBuffer = new SphereEntry[nSlots];
			if( nSlots > 0 ) PartSort( 0, nSlots, SortBuffer );
			//SortBuffer;
		}
Beispiel #3
0
		public static void GetEntry( int EntryNum, out SphereEntry result ) { result = SectorList[EntryNum]; }