DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ SortedInsertEx()

int ServerBrowserTab::SortedInsertEx ( GetServersResultRow entry,
ESortType sortType,
bool isDescending )
inlineprivate

См. определение в файле ServerBrowserTabPc.c строка 709

710 {
711 array<ref GetServersResultRow> list = m_EntriesSorted[sortType];
712 int indexMax = list.Count() - 1;
713 int indexMin = 0;
714 int targetIndex = Math.Floor( indexMax / 2 );
715 int comparisonMultiplier = 1;
716
717 // if order is descending, then invert comparison results
718 if (isDescending == true)
719 {
720 comparisonMultiplier = -1;
721 }
722
723 if ( indexMax == -1 )
724 {
725 list.Insert( entry );
726 return 0;
727 }
728
729 while ( true )
730 {
731 int comparisonResult = comparisonMultiplier * entry.CompareTo(list[targetIndex], sortType);
732
733 if ((indexMax - indexMin) <= 1)
734 {
735 for (int i = indexMin; i <= indexMax; i++ )
736 {
737 comparisonResult = comparisonMultiplier * entry.CompareTo(list[i], sortType);
738
739 if ( comparisonResult > 0 )
740 {
741 list.InsertAt( entry, i );
742 return i;
743 }
744 }
745
746 // adding entry AFTER indexMax
747 targetIndex = Math.Min(indexMax + 1, list.Count());
748 list.InsertAt(entry, targetIndex);
749 return targetIndex;
750 }
751
752 if (comparisonResult == 0)
753 {
754 list.InsertAt(entry, targetIndex);
755 return targetIndex;
756 }
757
758 if (comparisonResult > 0)
759 {
760 indexMax = targetIndex;
761 }
762
763 else if (comparisonResult < 0)
764 {
765 indexMin = targetIndex;
766 }
767
768 targetIndex = indexMin + Math.Floor((indexMax - indexMin) / 2);
769 }
770
771 return 0;
772 }
ref map< ESortType, ref array< ref GetServersResultRow > > m_EntriesSorted
Определения ServerBrowserTab.c:75
int CompareTo(GetServersResultRow other, ESortType sortType)
Определения BiosLobbyService.c:298

Перекрестные ссылки GetServersResultRow::CompareTo(), Math::Floor(), m_EntriesSorted и Math::Min().

Используется в SortedInsert().