-
-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathEntry.ts
62 lines (55 loc) · 1.25 KB
/
Entry.ts
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
//================================================================
/**
* @packageDocumentation
* @module std
*/
//================================================================
import { IComparable } from "../functional/IComparable";
import { equal_to, less as less_fn } from "../functional/comparators";
import { hash } from "../functional/hash";
import { IPair } from "./IPair";
/**
* Entry for mapping.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export class Entry<Key, T>
implements Readonly<IPair<Key, T>>, IComparable<Entry<Key, T>>
{
/**
* The first, key element.
*/
public readonly first: Key;
/**
* The second, mapped element.
*/
public second: T;
/**
* Intializer Constructor.
*
* @param first The first, key element.
* @param second The second, mapped element.
*/
public constructor(first: Key, second: T) {
this.first = first;
this.second = second;
}
/**
* @inheritDoc
*/
public equals(obj: Entry<Key, T>): boolean {
return equal_to(this.first, obj.first);
}
/**
* @inheritDoc
*/
public less(obj: Entry<Key, T>): boolean {
return less_fn(this.first, obj.first);
}
/**
* @inheritDoc
*/
public hashCode(): number {
return hash(this.first);
}
}