Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Contents of /trunk/src/waysx.h
Parent Directory
|
Revision Log
Revision 216 -
(show annotations)
(download)
(as text)
Sat Jul 4 17:58:06 2009 UTC (15 years, 8 months ago) by amb
File MIME type: text/x-chdr
File size: 2870 byte(s)
Sat Jul 4 17:58:06 2009 UTC (15 years, 8 months ago) by amb
File MIME type: text/x-chdr
File size: 2870 byte(s)
Change data structure to avoid calling realloc() each time to allocate more memory.
1 | /*************************************** |
2 | $Header: /home/amb/CVS/routino/src/waysx.h,v 1.11 2009-07-04 17:58:06 amb Exp $ |
3 | |
4 | A header file for the extended Ways structure. |
5 | |
6 | Part of the Routino routing software. |
7 | ******************/ /****************** |
8 | This file Copyright 2008,2009 Andrew M. Bishop |
9 | |
10 | This program is free software: you can redistribute it and/or modify |
11 | it under the terms of the GNU Affero General Public License as published by |
12 | the Free Software Foundation, either version 3 of the License, or |
13 | (at your option) any later version. |
14 | |
15 | This program is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | GNU Affero General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU Affero General Public License |
21 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | ***************************************/ |
23 | |
24 | |
25 | #ifndef WAYSX_H |
26 | #define WAYSX_H /*+ To stop multiple inclusions. +*/ |
27 | |
28 | #include <stdint.h> |
29 | |
30 | #include "typesx.h" |
31 | #include "types.h" |
32 | #include "ways.h" |
33 | |
34 | |
35 | /* Data structures */ |
36 | |
37 | |
38 | /*+ An extended structure containing a single way. +*/ |
39 | struct _WayX |
40 | { |
41 | way_t id; /*+ The way identifier. +*/ |
42 | |
43 | char *name; /*+ The name of the way. +*/ |
44 | |
45 | Way *way; /*+ A pointer to the real Way data. +*/ |
46 | }; |
47 | |
48 | |
49 | /*+ A structure containing a set of ways (memory format). +*/ |
50 | struct _WaysX |
51 | { |
52 | uint32_t sorted; /*+ Is the data sorted? +*/ |
53 | |
54 | int32_t row; /*+ How many rows are allocated? +*/ |
55 | uint32_t col; /*+ How many columns are used in the last row? +*/ |
56 | |
57 | WayX **xdata; /*+ The extended data for the Ways (unsorted). +*/ |
58 | |
59 | uint32_t number; /*+ How many entries are still useful? +*/ |
60 | |
61 | WayX **idata; /*+ The extended data for the Ways (sorted by ID). +*/ |
62 | WayX **ndata; /*+ The extended data for the Ways (sorted by name and way properties). +*/ |
63 | |
64 | int32_t wrow; /*+ How many rows are allocated? +*/ |
65 | uint32_t wcol; /*+ How many columns are used in the last row? +*/ |
66 | |
67 | Way **wxdata; /*+ The data for the Ways (unsorted). +*/ |
68 | Way **wdata; /*+ The data for the Ways (sorted like ndata and compacted). +*/ |
69 | |
70 | char *names; /*+ The array containing all the names. +*/ |
71 | |
72 | uint32_t length; /*+ How long is the string of name entries? +*/ |
73 | }; |
74 | |
75 | |
76 | /* Functions */ |
77 | |
78 | |
79 | WaysX *NewWayList(void); |
80 | |
81 | void SaveWayList(WaysX *waysx,const char *filename); |
82 | |
83 | WayX *FindWayX(WaysX* waysx,way_t id); |
84 | |
85 | Way *AppendWay(WaysX* waysx,way_t id,const char *name); |
86 | |
87 | void SortWayList(WaysX *waysx); |
88 | |
89 | index_t IndexWayInWaysX(WaysX *waysx,WayX *wayx); |
90 | |
91 | #endif /* WAYSX_H */ |
Properties
Name | Value |
---|---|
cvs:description | Extended ways header. |