Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
isochrone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Institut für Informatik
dbis
dbis-isochrone
isochrone
Commits
9ef41c63
Commit
9ef41c63
authored
10 years ago
by
User expired
Browse files
Options
Downloads
Patches
Plain Diff
added toString method (for debugging purpose9
sorting methods
parent
e8e4759a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/it/unibz/inf/isochrone/network/Node.java
+78
-68
78 additions, 68 deletions
src/main/java/it/unibz/inf/isochrone/network/Node.java
with
78 additions
and
68 deletions
src/main/java/it/unibz/inf/isochrone/network/Node.java
+
78
−
68
View file @
9ef41c63
...
...
@@ -41,61 +41,7 @@ public class Node implements Comparable<Node> {
routes
=
new
Hashtable
<>();
}
// Public methods
public
void
addAdjLink
(
final
Link
link
)
{
if
(
adjLinks
==
null
)
{
adjLinks
=
new
ArrayList
<>();
}
adjLinks
.
add
(
link
);
}
public
void
addRoute
(
final
int
routeId
)
{
if
(!
routes
.
containsKey
(
routeId
))
{
routes
.
put
(
routeId
,
new
Schedule
());
}
}
public
void
close
()
{
closed
=
true
;
}
@Override
public
int
compareTo
(
final
Node
other
)
{
if
(
other
==
null
)
{
return
-
1
;
}
if
(
distance
<
other
.
distance
)
{
return
-
1
;
}
if
(
distance
>
other
.
distance
)
{
return
1
;
}
return
id
-
other
.
id
;
}
public
boolean
containsRoutes
()
{
return
!
routes
.
isEmpty
();
}
@Override
public
boolean
equals
(
final
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(
obj
==
null
||
getClass
()
!=
obj
.
getClass
())
{
return
false
;
}
final
Node
other
=
(
Node
)
obj
;
if
(
id
!=
other
.
id
||
Double
.
doubleToLongBits
(
distance
)
!=
Double
.
doubleToLongBits
(
other
.
distance
))
{
return
false
;
}
return
true
;
}
// Getter
public
Collection
<
Link
>
getAdjLinks
()
{
return
adjLinks
;
...
...
@@ -140,19 +86,6 @@ public class Node implements Comparable<Node> {
return
"OPEN"
;
}
@Override
public
int
hashCode
()
{
int
result
=
1
;
final
int
prime
=
31
;
final
long
temp
=
Double
.
doubleToLongBits
(
distance
);
// CHECKSTYLE:OFF MagicNumber
result
=
prime
*
result
+
(
int
)
(
temp
^
temp
>>>
32
);
result
=
prime
*
result
+
id
;
// CHECKSTYLE:ON MagicNumber
return
result
;
}
public
boolean
isClosed
()
{
return
closed
;
...
...
@@ -162,6 +95,8 @@ public class Node implements Comparable<Node> {
return
getNrAdjacentLinks
()
==
0
;
}
// Setter
public
void
setAdjLinks
(
final
Collection
<
Link
>
adjLinks
)
{
this
.
adjLinks
=
adjLinks
;
}
...
...
@@ -196,6 +131,81 @@ public class Node implements Comparable<Node> {
this
.
radius
=
radius
;
}
// Public methods
public
void
addAdjLink
(
final
Link
link
)
{
if
(
adjLinks
==
null
)
{
adjLinks
=
new
ArrayList
<>();
}
adjLinks
.
add
(
link
);
}
public
void
addRoute
(
final
int
routeId
)
{
if
(!
routes
.
containsKey
(
routeId
))
{
routes
.
put
(
routeId
,
new
Schedule
());
}
}
public
void
close
()
{
closed
=
true
;
}
@Override
public
int
compareTo
(
final
Node
other
)
{
if
(
other
==
null
)
{
return
-
1
;
}
if
(
distance
<
other
.
distance
)
{
return
-
1
;
}
if
(
distance
>
other
.
distance
)
{
return
1
;
}
return
id
-
other
.
id
;
}
public
boolean
containsRoutes
()
{
return
!
routes
.
isEmpty
();
}
@Override
public
boolean
equals
(
final
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(
obj
==
null
||
getClass
()
!=
obj
.
getClass
())
{
return
false
;
}
final
Node
other
=
(
Node
)
obj
;
if
(
id
!=
other
.
id
||
Double
.
doubleToLongBits
(
distance
)
!=
Double
.
doubleToLongBits
(
other
.
distance
))
{
return
false
;
}
return
true
;
}
@Override
public
int
hashCode
()
{
int
result
=
1
;
final
int
prime
=
31
;
final
long
temp
=
Double
.
doubleToLongBits
(
distance
);
// CHECKSTYLE:OFF MagicNumber
result
=
prime
*
result
+
(
int
)
(
temp
^
temp
>>>
32
);
result
=
prime
*
result
+
id
;
// CHECKSTYLE:ON MagicNumber
return
result
;
}
@Override
public
String
toString
()
{
return
"Node [id="
+
id
+
", distance="
+
distance
+
"]"
;
}
public
void
visitNrAdjacentLinks
(
final
int
links
)
{
nrAdjacentLinks
-=
links
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment