Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Annotation of /trunk/src/results.h
Parent Directory
|
Revision Log
Revision 79 -
(hide annotations)
(download)
(as text)
Sat Jan 24 16:21:44 2009 UTC (16 years, 2 months ago) by amb
File MIME type: text/x-chdr
File size: 3047 byte(s)
Sat Jan 24 16:21:44 2009 UTC (16 years, 2 months ago) by amb
File MIME type: text/x-chdr
File size: 3047 byte(s)
Change the Results structure so that the real data doesn't need to be realloc(). Add functions to access the first and subsequent elements of the Results structure.
1 | amb | 29 | /*************************************** |
2 | amb | 79 | $Header: /home/amb/CVS/routino/src/results.h,v 1.8 2009-01-24 16:21:44 amb Exp $ |
3 | amb | 29 | |
4 | A header file for the results. | ||
5 | ******************/ /****************** | ||
6 | Written by Andrew M. Bishop | ||
7 | |||
8 | This file Copyright 2009 Andrew M. Bishop | ||
9 | It may be distributed under the GNU Public License, version 2, or | ||
10 | any higher version. See section COPYING of the GNU Public license | ||
11 | for conditions under which this file may be redistributed. | ||
12 | ***************************************/ | ||
13 | |||
14 | |||
15 | #ifndef RESULTS_H | ||
16 | #define RESULTS_H /*+ To stop multiple inclusions. +*/ | ||
17 | |||
18 | #include <stdint.h> | ||
19 | |||
20 | #include "nodes.h" | ||
21 | #include "segments.h" | ||
22 | |||
23 | |||
24 | /* Data structures */ | ||
25 | |||
26 | /*+ One part of the result for a node. +*/ | ||
27 | typedef struct _HalfResult | ||
28 | { | ||
29 | amb | 43 | node_t prev; /*+ The previous node following the shortest path. +*/ |
30 | node_t next; /*+ The next node following the shortest path. +*/ | ||
31 | amb | 29 | distance_t distance; /*+ The distance travelled to the node following the shortest path. +*/ |
32 | duration_t duration; /*+ The time taken to the node following the shortest path. +*/ | ||
33 | } | ||
34 | HalfResult; | ||
35 | |||
36 | /*+ One complete result for a node. +*/ | ||
37 | typedef struct _Result | ||
38 | { | ||
39 | amb | 43 | node_t node; /*+ The node for which this result applies. +*/ |
40 | amb | 29 | HalfResult shortest; /*+ The result for the shortest path. +*/ |
41 | HalfResult quickest; /*+ The result for the quickest path. +*/ | ||
42 | } | ||
43 | Result; | ||
44 | |||
45 | /*+ A list of results. +*/ | ||
46 | typedef struct _Results | ||
47 | { | ||
48 | amb | 71 | uint32_t nbins; /*+ The number of bins. +*/ |
49 | uint32_t mask; /*+ A bit mask to select the bottom 'nbins' bits. +*/ | ||
50 | |||
51 | amb | 79 | uint32_t alloced; /*+ The amount of space allocated for results |
52 | (the length of the number and pointers arrays and | ||
53 | 1/nbins times the amount in the real results). +*/ | ||
54 | amb | 45 | uint32_t number; /*+ The total number of occupied results. +*/ |
55 | amb | 71 | |
56 | amb | 79 | uint32_t *count; /*+ An array of nbins counters of results in each array. +*/ |
57 | Result ***point; /*+ An array of nbins arrays of pointers to actual results. +*/ | ||
58 | amb | 71 | |
59 | amb | 79 | Result **data; /*+ An array of arrays containing the actual results |
60 | (don't need to realloc the array of data when adding more, | ||
61 | only realloc the array that points to the array of data). | ||
62 | Most importantly pointers into the real data don't change | ||
63 | as more space is allocted (since realloc is not being used). +*/ | ||
64 | amb | 29 | } |
65 | Results; | ||
66 | |||
67 | |||
68 | /* Functions */ | ||
69 | |||
70 | amb | 71 | Results *NewResultsList(int nbins); |
71 | amb | 29 | void FreeResultsList(Results *results); |
72 | |||
73 | Result *InsertResult(Results *results,node_t node); | ||
74 | |||
75 | Result *FindResult(Results *results,node_t node); | ||
76 | |||
77 | amb | 79 | Result *FirstResult(Results *results); |
78 | Result *NextResult(Results *results,Result *result); | ||
79 | amb | 29 | |
80 | amb | 67 | /* Queue Functions */ |
81 | |||
82 | amb | 79 | void insert_in_queue(Result *result); |
83 | Result *pop_from_queue(void); | ||
84 | amb | 67 | |
85 | |||
86 | amb | 29 | #endif /* RESULTS_H */ |
Properties
Name | Value |
---|---|
cvs:description | Results data type. |