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

◆ SortedInsertAsc()

int ServerBrowserTab::SortedInsertAsc ( GetServersResultRow entry,
ESortType sort_type )
inlineprivate

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

773 {
774 array<ref GetServersResultRow> list = m_EntriesSorted[sort_type];
775
776 int i;
777 int index_min = 0;
778 int index_max = list.Count() - 1;
779 int target_index = Math.Floor( index_max / 2 );
780
781 if ( index_max == -1 )
782 {
783 list.Insert( entry );
784 return 0;
785 }
786
787 if ( sort_type == ESortType.HOST )
788 {
789 string entry_value_str = entry.GetValueStr(ESortType.HOST);
790
791 while ( true )
792 {
793 string target_value_str = list[target_index].GetValueStr(ESortType.HOST);
794
795 if ( entry_value_str == target_value_str || ((index_max - index_min) <= 1) )
796 {
797 for ( i = index_min; i <= index_max; i++ )
798 {
799 if ( entry_value_str <= list[i].GetValueStr(ESortType.HOST) )
800 {
801 list.InsertAt( entry, i );
802 return i;
803 }
804 }
805
806 index_max++;
807 list.InsertAt( entry, index_max );
808 return target_index;
809 }
810 else if ( entry_value_str < target_value_str )
811 {
812 index_max = target_index;
813 target_index = Math.Floor( target_index / 2 );
814 }
815 else if ( entry_value_str > target_value_str )
816 {
817 index_min = target_index;
818 target_index += Math.Floor( (index_max - index_min) / 2 );
819 }
820 }
821 }
822 else
823 {
824 int entry_value_int = entry.GetValueInt( sort_type );
825
826 while ( true )
827 {
828 int target_value_int = list[target_index].GetValueInt( sort_type );
829
830 if ( entry_value_int == target_value_int || ((index_max - index_min) <= 1) )
831 {
832 for ( i = index_min; i <= index_max; i++ )
833 {
834 if ( entry_value_int <= list[i].GetValueInt( sort_type ) )
835 {
836 list.InsertAt( entry, i );
837 return i;
838 }
839 }
840
841 index_max++;
842 list.InsertAt( entry, index_max );
843 return target_index;
844 }
845 else if ( entry_value_int < target_value_int )
846 {
847 index_max = target_index;
848 target_index = Math.Floor( target_index / 2 );
849 }
850 else if ( entry_value_int > target_value_int )
851 {
852 index_min = target_index;
853 target_index += Math.Floor( (index_max - index_min) / 2 );
854 }
855 }
856 }
857
858 return target_index;
859 }
ESortType
Определения BiosLobbyService.c:33
ref map< ESortType, ref array< ref GetServersResultRow > > m_EntriesSorted
Определения ServerBrowserTab.c:75
string GetValueStr(ESortType sort_type)
Определения BiosLobbyService.c:248
int GetValueInt(ESortType sort_type)
Определения BiosLobbyService.c:268

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