File tree 3 files changed +11
-23
lines changed 3 files changed +11
-23
lines changed Original file line number Diff line number Diff line change @@ -158,7 +158,6 @@ var astar = {
158
158
function Graph ( gridIn , options ) {
159
159
options = options || { } ;
160
160
this . nodes = [ ] ;
161
- this . dirtyNodes = [ ] ;
162
161
this . diagonal = ! ! options . diagonal ;
163
162
this . grid = [ ] ;
164
163
for ( var x = 0 ; x < gridIn . length ; x ++ ) {
@@ -170,23 +169,24 @@ function Graph(gridIn, options) {
170
169
this . nodes . push ( node ) ;
171
170
}
172
171
}
173
- this . init ( this ) ;
172
+ this . init ( ) ;
174
173
}
175
174
176
- Graph . prototype . init = function ( ) {
177
- for ( var i = 0 , len = this . nodes . length ; i < len ; ++ i ) {
175
+ Graph . prototype . init = function ( ) {
176
+ this . dirtyNodes = [ ] ;
177
+ for ( var i = 0 ; i < this . nodes . length ; i ++ ) {
178
178
astar . cleanNode ( this . nodes [ i ] ) ;
179
179
}
180
180
} ;
181
181
182
- Graph . prototype . cleanDirty = function ( ) {
182
+ Graph . prototype . cleanDirty = function ( ) {
183
183
for ( var i = 0 ; i < this . dirtyNodes . length ; i ++ ) {
184
184
astar . cleanNode ( this . dirtyNodes [ i ] ) ;
185
185
}
186
- this . dirtyNodes . length = 0 ;
186
+ this . dirtyNodes = [ ] ;
187
187
} ;
188
188
189
- Graph . prototype . markDirty = function ( node ) {
189
+ Graph . prototype . markDirty = function ( node ) {
190
190
this . dirtyNodes . push ( node ) ;
191
191
} ;
192
192
Original file line number Diff line number Diff line change 7
7
< link rel ="stylesheet " type ="text/css " href ="../demo/demo.css " />
8
8
< script type ='text/javascript ' src ='../demo/jquery-1.7.1.min.js '> </ script >
9
9
< script type ='text/javascript ' src ='../astar.js '> </ script >
10
- < script type ='text/javascript ' src ='grid_150x150 .js '> </ script >
10
+ < script type ='text/javascript ' src ='grid_500x500 .js '> </ script >
11
11
< script type ='text/javascript ' src ='benchmark.js '> </ script >
12
12
</ head >
13
13
< body >
Original file line number Diff line number Diff line change @@ -135,7 +135,6 @@ test( "GPS Pathfinding", function() {
135
135
136
136
function CityGraph ( data , links ) {
137
137
this . nodes = [ ] ;
138
- this . dirtyNodes = [ ] ;
139
138
this . links = links ;
140
139
this . cities = { } ;
141
140
@@ -153,22 +152,11 @@ test( "GPS Pathfinding", function() {
153
152
this . init ( ) ;
154
153
}
155
154
156
- CityGraph . prototype . init = function ( ) {
157
- for ( var i = 0 , len = this . nodes . length ; i < len ; ++ i ) {
158
- astar . cleanNode ( this . nodes [ i ] ) ;
159
- }
160
- } ;
161
- CityGraph . prototype . cleanDirty = function ( ) {
162
- for ( var i = 0 ; i < this . dirtyNodes . length ; i ++ ) {
163
- astar . cleanNode ( this . dirtyNodes [ i ] ) ;
164
- }
165
- this . dirtyNodes . length = 0 ;
166
- } ;
155
+ CityGraph . prototype . init = Graph . prototype . init ;
167
156
168
- CityGraph . prototype . markDirty = function ( node ) {
169
- this . dirtyNodes . push ( node ) ;
170
- } ;
157
+ CityGraph . prototype . cleanDirty = Graph . prototype . cleanDirty ;
171
158
159
+ CityGraph . prototype . markDirty = Graph . prototype . markDirty ;
172
160
173
161
CityGraph . prototype . neighbors = function ( node ) {
174
162
var neighbors = [ ] ,
You can’t perform that action at this time.
0 commit comments