FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/DataStructures/Heaps/HeapElement.java at master · amit2014/Java · GitHub
amit2014
/
Java
Public
forked from
TheAlgorithms/Java
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java
/
DataStructures
/
Heaps
/
HeapElement.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
126 lines (109 loc) · 3.4 KB
Breadcrumbs
Java
/
DataStructures
/
Heaps
/
HeapElement.java
Copy path
File metadata and controls
126 lines (109 loc) · 3.4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/**
*
*/
package
DataStructures
.
Heaps
;
import
java
.
lang
.
Double
;
import
java
.
lang
.
Object
;
/**
* Class for heap elements.<br>
* <p>A heap element contains two attributes: a key which will be used to build the tree (int
* or double, either primitive type or object) and any kind of IMMUTABLE object the user sees fit
* to carry any information he/she likes. Be aware that the use of a mutable object might
* jeopardize the integrity of this information. </p>
*
* @author Nicolas Renard
*/
public
class
HeapElement
{
private
final
double
key
;
private
final
Object
additionalInfo
;
// Constructors
/**
* @param key : a number of primitive type 'double'
* @param info : any kind of IMMUTABLE object. May be null, since the purpose is only to carry
* additional information of use for the user
*/
public
HeapElement
(
double
key
,
Object
info
) {
this
.
key
=
key
;
this
.
additionalInfo
=
info
;
}
/**
* @param key : a number of primitive type 'int'
* @param info : any kind of IMMUTABLE object. May be null, since the purpose is only to carry
* additional information of use for the user
*/
public
HeapElement
(
int
key
,
Object
info
) {
this
.
key
=
key
;
this
.
additionalInfo
=
info
;
}
/**
* @param key : a number of object type 'Integer'
* @param info : any kind of IMMUTABLE object. May be null, since the purpose is only to carry
* additional information of use for the user
*/
public
HeapElement
(
Integer
key
,
Object
info
) {
this
.
key
=
key
;
this
.
additionalInfo
=
info
;
}
/**
* @param key : a number of object type 'Double'
* @param info : any kind of IMMUTABLE object. May be null, since the purpose is only to carry
* additional information of use for the user
*/
public
HeapElement
(
Double
key
,
Object
info
) {
this
.
key
=
key
;
this
.
additionalInfo
=
info
;
}
/**
* @param key : a number of primitive type 'double'
*/
public
HeapElement
(
double
key
) {
this
.
key
=
key
;
this
.
additionalInfo
=
null
;
}
/**
* @param key : a number of primitive type 'int'
*/
public
HeapElement
(
int
key
) {
this
.
key
=
key
;
this
.
additionalInfo
=
null
;
}
/**
* @param key : a number of object type 'Integer'
*/
public
HeapElement
(
Integer
key
) {
this
.
key
=
key
;
this
.
additionalInfo
=
null
;
}
/**
* @param key : a number of object type 'Double'
*/
public
HeapElement
(
Double
key
) {
this
.
key
=
key
;
this
.
additionalInfo
=
null
;
}
// Getters
/**
* @return the object containing the additional info provided by the user.
*/
public
Object
getInfo
() {
return
additionalInfo
;
}
/**
* @return the key value of the element
*/
public
double
getKey
() {
return
key
;
}
// Overridden object methods
public
String
toString
() {
return
"Key: "
+
key
+
" - "
+
additionalInfo
.
toString
();
}
/**
* @param otherHeapElement
* @return true if the keys on both elements are identical and the additional info objects
* are identical.
*/
public
boolean
equals
(
HeapElement
otherHeapElement
) {
return
(
this
.
key
==
otherHeapElement
.
key
) && (
this
.
additionalInfo
.
equals
(
otherHeapElement
.
additionalInfo
));
}
}
Back
|
FazBrowse Home
|
New Git URL