Reorganise and start working on the json parser
This commit is contained in:
26
haversine_02/include/aliases.h
Normal file
26
haversine_02/include/aliases.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef ALIASES_H
|
||||
#define ALIASES_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define u8 uint8_t
|
||||
#define u16 uint16_t
|
||||
#define u32 uint32_t
|
||||
#define u64 uint64_t
|
||||
|
||||
#define i8 int8_t
|
||||
#define i16 int16_t
|
||||
#define i32 int32_t
|
||||
#define i64 int64_t
|
||||
|
||||
#define f32 float
|
||||
#define f64 double
|
||||
|
||||
#define INTERNAL static
|
||||
#define PERSISTENT static
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define CLASS_MEMBER static
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // !ALIASES_H
|
||||
15
haversine_02/include/argparser.h
Normal file
15
haversine_02/include/argparser.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef ARGPARSER_H
|
||||
#define ARGPARSER_H
|
||||
|
||||
#include "aliases.h"
|
||||
#include <argp.h>
|
||||
|
||||
struct GeneratorArgs {
|
||||
u32 seed;
|
||||
bool clustered;
|
||||
u64 count;
|
||||
};
|
||||
|
||||
GeneratorArgs parse_args(i32 argc, char *argv[]);
|
||||
|
||||
#endif // !ARGPARSER_H
|
||||
8
haversine_02/include/generator.h
Normal file
8
haversine_02/include/generator.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef GENERATOR_H
|
||||
#define GENERATOR_H
|
||||
|
||||
#include "point_types.h"
|
||||
|
||||
void fill_pairs_array(PairArray *pairs, bool clustered);
|
||||
|
||||
#endif // !GENERATOR_H
|
||||
9
haversine_02/include/haversine.h
Normal file
9
haversine_02/include/haversine.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef HAVERSINE_H
|
||||
#define HAVERSINE_H
|
||||
|
||||
#include "aliases.h"
|
||||
#include "point_types.h"
|
||||
|
||||
f64 haversine_of_degrees(const PointPair &pair, f64 radius);
|
||||
|
||||
#endif // !HAVERSINE_H
|
||||
27
haversine_02/include/point_types.h
Normal file
27
haversine_02/include/point_types.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef POINT_H
|
||||
#define POINT_H
|
||||
|
||||
#include "aliases.h"
|
||||
#include <stdio.h>
|
||||
|
||||
struct Point {
|
||||
f64 x;
|
||||
f64 y;
|
||||
};
|
||||
|
||||
struct PointPair {
|
||||
Point p1;
|
||||
Point p2;
|
||||
};
|
||||
|
||||
struct PairArray {
|
||||
u64 count;
|
||||
PointPair *pairs;
|
||||
};
|
||||
|
||||
void write_pairs_to_binary(const PairArray &arr, const char *filename);
|
||||
void read_pairs_from_binary(PairArray &arr, const char *filename);
|
||||
void write_pairs_to_json(const PairArray &arr, const char *filename);
|
||||
bool compare_pair_array(const PairArray &arr1, const PairArray &arr2);
|
||||
|
||||
#endif // !POINT_H
|
||||
Reference in New Issue
Block a user