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

◆ SortedInsert()

int MissionBase::SortedInsert ( array< int > list,
int number )
inlineprivate

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

147 {
148 int find_number = number;
149 int index_min = 0;
150 int index_max = list.Count() - 1;
151 int target_index = Math.Floor( index_max / 2 );
152
153 if ( index_max == -1 )
154 {
155 list.Insert( number );
156 return 0;
157 }
158
159 while ( true )
160 {
161 int target_value = list[target_index];
162
163 if ( find_number == target_value || ((index_max - index_min) <= 1) )
164 {
165 for ( int i = index_min; i <= index_max; i++ )
166 {
167 if ( find_number <= list[i] )
168 {
169 list.InsertAt( find_number, i );
170 return i;
171 }
172 }
173
174 index_max++;
175 list.InsertAt( find_number, index_max );
176 return target_index;
177 }
178 else if ( find_number < target_value )
179 {
180 index_max = target_index;
181 target_index = Math.Floor( target_index / 2 );
182 }
183 else if ( find_number > target_value )
184 {
185 index_min = target_index;
186 target_index += Math.Floor( (index_max - index_min) / 2 );
187 }
188 }
189
190 return target_index;
191 }

Перекрестные ссылки Math::Floor().