This commit is contained in:
Nikolaj
2021-10-07 14:50:32 +02:00
parent c88726146e
commit 8f39ccb72c
3 changed files with 6 additions and 4 deletions

1
.gitignore vendored
View File

@ -8,6 +8,7 @@ A1/coord_query_naive
A1/id_query_naive
A1/id_query_indexed
A1/id_query_binsort
A1/random_ids
*/.vscode/
.vscode/

View File

@ -16,13 +16,13 @@ double closest_point_distance;
int lon_comp_func(const void* a, const void* b) {
return (
((struct record*)a)->lon - ((struct record*)b)->lon
((struct record*)a)->lon > ((struct record*)b)->lon
);
}
int lat_comp_func(const void* a, const void* b) {
return (
((struct record*)a)->lat - ((struct record*)b)->lat
((struct record*)a)->lat > ((struct record*)b)->lat
);
}

View File

@ -22,7 +22,7 @@ struct indexed_data {
int comp_func(const void* a, const void* b) {
return (
((struct index_record*)a)->osm_id - ((struct index_record*)b)->osm_id
((struct index_record*)a)->osm_id > ((struct index_record*)b)->osm_id
);
}
@ -48,8 +48,9 @@ void free_indexed(struct indexed_data* data) {
const struct record* lookup_indexed(struct indexed_data *data, int64_t needle) {
int bottom = 0;
int top = data->n;
int mid;
while (top >= bottom) {
int mid = bottom + ((top - bottom) / 2);
mid = bottom + ((top - bottom) / 2);
if ((&data->irs[mid])->osm_id < needle) {
bottom = mid + 1;
}