42 #include <unordered_map>
100 assert(p_index > current_end);
101 U32 diff = p_index - current_end;
103 if (diff > threshold)
169 if (num_indices == 1)
176 ((
my_cell_hash*)
cells)->insert(my_cell_hash::value_type(new_index, (*hash_element).second));
182 for (i = 0; i < num_indices; i++)
204 maximum_intervals = 0;
217 cell = (*hash_element).second;
221 map.insert(my_cell_map::value_type(diff, cell));
227 my_cell_map::iterator map_element =
map.begin();
228 diff = (*map_element).first;
231 if (
map.size() <= maximum_intervals)
233 fprintf(stderr,
"next largest interval gap is %u\n", diff);
238 while (size > maximum_intervals)
240 map_element =
map.begin();
241 diff = (*map_element).first;
242 cell = (*map_element).second;
243 map.erase(map_element);
251 delete_cell = cell->
next;
252 cell->
end = delete_cell->
end;
256 map.insert(my_cell_map::value_type(cell->
next->
start - cell->
end - 1, cell));
257 delete_cell->
end = 0;
267 map_element =
map.begin();
270 if (map_element ==
map.end())
break;
271 cell = (*map_element).second;
279 fprintf(stderr,
"largest interval gap increased to %u\n", diff);
287 start_cell = (*hash_element).second;
288 start_cell->
total = 0;
307 my_cell_hash::iterator hash_element;
324 index = (*hash_element).first;
325 full = (*hash_element).second->full;
326 total = (*hash_element).second->total;
339 index = (*hash_element).first;
340 full = (*hash_element).second->full;
341 total = (*hash_element).second->total;
387 next_next = next->
next;
417 cell = (*set_element);
421 map.insert(my_cell_map::value_type(cell->
start, cell));
427 my_cell_map::iterator map_element =
map.begin();
428 cell = (*map_element).second;
429 map.erase(map_element);
433 if (erase)
delete cell;
439 map_element =
map.begin();
440 cell = (*map_element).second;
441 map.erase(map_element);
459 if (erase)
delete cell;
522 try { stream->
getBytes((
U8*)signature, 4); }
catch (...)
524 fprintf(stderr,
"ERROR (LASinterval): reading signature\n");
527 if (strncmp(signature,
"LASV", 4) != 0)
529 fprintf(stderr,
"ERROR (LASinterval): wrong signature %4s instead of 'LASV'\n", signature);
535 fprintf(stderr,
"ERROR (LASinterval): reading version\n");
542 fprintf(stderr,
"ERROR (LASinterval): reading number of cells\n");
552 fprintf(stderr,
"ERROR (LASinterval): reading cell index\n");
557 ((
my_cell_hash*)
cells)->insert(my_cell_hash::value_type(cell_index, start_cell));
563 fprintf(stderr,
"ERROR (LASinterval): reading number of intervals in cell\n");
568 try { stream->
get32bitsLE((
U8*)&number_points); }
catch (...)
570 fprintf(stderr,
"ERROR (LASinterval): reading number of points in cell\n");
573 start_cell->
full = number_points;
574 start_cell->
total = 0;
580 fprintf(stderr,
"ERROR (LASinterval): reading start %d of interval\n", cell->
start);
586 fprintf(stderr,
"ERROR (LASinterval): reading end %d of interval\n", cell->
end);
607 fprintf(stderr,
"ERROR (LASinterval): writing signature\n");
613 fprintf(stderr,
"ERROR (LASinterval): writing version\n");
620 fprintf(stderr,
"ERROR (LASinterval): writing number of cells %d\n", number_cells);
637 I32 cell_index = (*hash_element).first;
640 fprintf(stderr,
"ERROR (LASinterval): writing cell index %d\n", cell_index);
646 fprintf(stderr,
"ERROR (LASinterval): writing number of intervals %d in cell\n",
number_intervals);
652 fprintf(stderr,
"ERROR (LASinterval): writing number of points %d in cell\n", number_points);
656 cell = (*hash_element).second;
662 fprintf(stderr,
"ERROR (LASinterval): writing start %d of interval\n", cell->
start);
668 fprintf(stderr,
"ERROR (LASinterval): writing end %d of interval\n", cell->
end);