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

◆ SortedInsertEx()

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

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

693 {
694 array<ref GetServersResultRow> list = m_EntriesSorted[sortType];
695 int indexMax = list.Count() - 1;
696 int indexMin = 0;
697 int targetIndex = Math.Floor( indexMax / 2 );
698 int comparisonMultiplier = 1;
699
700 // if order is descending, then invert comparison results
701 if (isDescending == true)
702 {
703 comparisonMultiplier = -1;
704 }
705
706 if ( indexMax == -1 )
707 {
708 list.Insert( entry );
709 return 0;
710 }
711
712 while ( true )
713 {
714 int comparisonResult = comparisonMultiplier * entry.CompareTo(list[targetIndex], sortType);
715
716 if ((indexMax - indexMin) <= 1)
717 {
718 for (int i = indexMin; i <= indexMax; i++ )
719 {
720 comparisonResult = comparisonMultiplier * entry.CompareTo(list[i], sortType);
721
722 if ( comparisonResult > 0 )
723 {
724 list.InsertAt( entry, i );
725 return i;
726 }
727 }
728
729 // adding entry AFTER indexMax
730 targetIndex = Math.Min(indexMax + 1, list.Count());
731 list.InsertAt(entry, targetIndex);
732 return targetIndex;
733 }
734
735 if (comparisonResult == 0)
736 {
737 list.InsertAt(entry, targetIndex);
738 return targetIndex;
739 }
740
741 if (comparisonResult > 0)
742 {
743 indexMax = targetIndex;
744 }
745
746 else if (comparisonResult < 0)
747 {
748 indexMin = targetIndex;
749 }
750
751 targetIndex = indexMin + Math.Floor((indexMax - indexMin) / 2);
752 }
753
754 return 0;
755 }
ref map< ESortType, ref array< ref GetServersResultRow > > m_EntriesSorted
Определения ServerBrowserTab.c:75
int CompareTo(GetServersResultRow other, ESortType sortType)
Определения BiosLobbyService.c:272

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

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