Debian Codegraph @

closure-library/closure/goog/structs/node.js

raw
1 // Copyright 2006 The Closure Library Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS-IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 /**
16 * @fileoverview Generic immutable node object to be used in collections.
17 *
18 */
19
20
21 goog.provide('goog.structs.Node');
22
23
24
25 /**
26 * A generic immutable node. This can be used in various collections that
27 * require a node object for its item (such as a heap).
28 * @param {K} key Key.
29 * @param {V} value Value.
30 * @constructor
31 * @template K, V
32 */
33 goog.structs.Node = function(key, value) {
34 /**
35 * The key.
36 * @private {K}
37 */
38 this.key_ = key;
39
40 /**
41 * The value.
42 * @private {V}
43 */
44 this.value_ = value;
45 };
46
47
48 /**
49 * Gets the key.
50 * @return {K} The key.
51 */
52 goog.structs.Node.prototype.getKey = function() {
53 return this.key_;
54 };
55
56
57 /**
58 * Gets the value.
59 * @return {V} The value.
60 */
61 goog.structs.Node.prototype.getValue = function() {
62 return this.value_;
63 };
64
65
66 /**
67 * Clones a node and returns a new node.
68 * @return {!goog.structs.Node<K, V>} A new goog.structs.Node with the same
69 * key value pair.
70 */
71 goog.structs.Node.prototype.clone = function() {
72 return new goog.structs.Node(this.key_, this.value_);
73 };