Subversion Repositories tendra.SVN

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2006 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
Line 66... Line 96...
66
#include "solve-cycles.h"
96
#include "solve-cycles.h"
67
 
97
 
68
/*--------------------------------------------------------------------------*/
98
/*--------------------------------------------------------------------------*/
69
 
99
 
70
MapEntryP
100
MapEntryP
71
map_entry_create PROTO_N ((key, next, count))
101
map_entry_create(NStringP  key,			  MapEntryP next, 
72
		 PROTO_T (NStringP  key X
-
 
73
			  MapEntryP next X
-
 
74
			  unsigned  count)
102
			  unsigned  count)
75
{
103
{
76
    MapEntryP entry = ALLOCATE (MapEntryT);
104
    MapEntryP entry = ALLOCATE(MapEntryT);
77
 
105
 
78
    entry->next  = next;
106
    entry->next  = next;
79
    nstring_copy (&(entry->key), key);
107
    nstring_copy(& (entry->key), key);
80
    entry->count = count;
108
    entry->count = count;
81
    return (entry);
109
    return(entry);
82
}
110
}
83
 
111
 
84
MapEntryP
112
MapEntryP
85
map_entry_next PROTO_N ((entry))
113
map_entry_next(MapEntryP entry)
86
	       PROTO_T (MapEntryP entry)
-
 
87
{
114
{
88
    return (entry->next);
115
    return(entry->next);
89
}
116
}
90
 
117
 
91
NStringP
118
NStringP
92
map_entry_key PROTO_N ((entry))
119
map_entry_key(MapEntryP entry)
93
	      PROTO_T (MapEntryP entry)
-
 
94
{
120
{
95
    return (&(entry->key));
121
    return(& (entry->key));
96
}
122
}
97
 
123
 
98
void
124
void
99
map_entry_set_num_links PROTO_N ((entry, num_links))
125
map_entry_set_num_links(MapEntryP entry,				 unsigned  num_links)
100
			PROTO_T (MapEntryP entry X
-
 
101
				 unsigned  num_links)
-
 
102
{
126
{
103
    entry->num_links = num_links;
127
    entry->num_links = num_links;
104
    entry->links     = ALLOCATE_VECTOR (MapLinkT, num_links);
128
    entry->links     = ALLOCATE_VECTOR(MapLinkT, num_links);
105
}
129
}
106
 
130
 
107
void
131
void
108
map_entry_set_link PROTO_N ((entry, link, internal, external))
132
map_entry_set_link(MapEntryP entry,			    unsigned  link, 
109
		   PROTO_T (MapEntryP entry X
-
 
110
			    unsigned  link X
-
 
111
			    unsigned  internal X
133
			    unsigned  internal, 
112
			    unsigned  external)
134
			    unsigned  external)
113
{
135
{
114
    ASSERT (link < entry->num_links);
136
    ASSERT(link < entry->num_links);
115
    entry->links [link].internal = internal;
137
    entry->links[link].internal = internal;
116
    entry->links [link].external = external;
138
    entry->links[link].external = external;
117
}
139
}
118
 
140
 
119
unsigned
141
unsigned
120
map_entry_get_count PROTO_N ((entry))
142
map_entry_get_count(MapEntryP entry)
121
		    PROTO_T (MapEntryP entry)
-
 
122
{
143
{
123
    return (entry->count);
144
    return(entry->count);
124
}
145
}
125
 
146
 
126
unsigned
147
unsigned
127
map_entry_get_num_links PROTO_N ((entry))
148
map_entry_get_num_links(MapEntryP entry)
128
			PROTO_T (MapEntryP entry)
-
 
129
{
149
{
130
    return (entry->num_links);
150
    return(entry->num_links);
131
}
151
}
132
 
152
 
133
void
153
void
134
map_entry_get_link PROTO_N ((entry, link, internal_ref, external_ref))
154
map_entry_get_link(MapEntryP entry,			    unsigned  link, 
135
		   PROTO_T (MapEntryP entry X
-
 
136
			    unsigned  link X
-
 
137
			    unsigned *internal_ref X
155
			    unsigned *internal_ref, 
138
			    unsigned *external_ref)
156
			    unsigned *external_ref)
139
{
157
{
140
    ASSERT (link < entry->num_links);
158
    ASSERT(link < entry->num_links);
141
    *internal_ref = entry->links [link].internal;
159
    *internal_ref = entry->links[link].internal;
142
    *external_ref = entry->links [link].external;
160
    *external_ref = entry->links[link].external;
143
}
161
}
144
 
162
 
145
/*--------------------------------------------------------------------------*/
163
/*--------------------------------------------------------------------------*/
146
 
164
 
147
void
165
void
148
map_entry_check_non_empty PROTO_N ((entry, gclosure))
166
map_entry_check_non_empty(MapEntryP entry,				   GenericP  gclosure)
149
			  PROTO_T (MapEntryP entry X
-
 
150
				   GenericP  gclosure)
-
 
151
{
167
{
152
    ShapeTableP table = (ShapeTableP) gclosure;
168
    ShapeTableP table = (ShapeTableP)gclosure;
153
 
169
 
154
    if (entry->count > 0) {
170
    if (entry->count > 0) {
155
	NStringP    key         = map_entry_key (entry);
171
	NStringP    key         = map_entry_key(entry);
156
	ShapeEntryP shape_entry = shape_table_get (table, key);
172
	ShapeEntryP shape_entry = shape_table_get(table, key);
157
 
173
 
158
	shape_entry_set_non_empty (shape_entry);
174
	shape_entry_set_non_empty(shape_entry);
159
    }
175
    }
160
}
176
}
161

177

162
/*
178
/*
163
 * Local variables(smf):
179
 * Local variables(smf):