The type of the key value.
The type of the value.
Constructor of Entry.
KeyType element it'd better be distinguishable.
ValueType element.
Returns the key of this key/value pair.
The Key of this key/value pair.
Returns the value of key/value pair.
The value of this key/value pair.
Class Entry implements KoconutEquatable. The equality check process of this is done simply by using '==' operator when the KeyType is not KoconutEquatable, otherwise, by using the method 'equalsTo' to the the key element. Please, have a check following example.
class MyKey {
private keyString : string
constructor(keyString : string) {
this.keyString = keyString
}
}
class MyEquatableKey implements KoconutEquatable {
private keyString : string
constructor(keyString : string) {
this.keyString = keyString
}
equalsTo(other : MyEquatableKey) {
return this.keyString == other.keyString
}
}
const myKeyEntry = Entry.from([new MyKey("myKeyString"), 0])
const myKeyEntry2 = Entry.from([new MyKey("myKeyString"), 0])
console.log(`${myKeyEntry.equalsTo(myKeyEntry2)}`)
// ↑ false
const myEquatableKeyEntry = Entry.from([new MyEquatableKey("myEquatableKeyString"), 0])
const myEquatableKeyEntry2 = Entry.from([new MyEquatableKey("myEquatableKeyString"), 0])
console.log(`${myEquatableKeyEntry.equalsTo(myEquatableKeyEntry2)}`)
// ↑ true
Turns this Entry instance into a simple array.
const myEntry = Entry.from(["Apex", "Captain"])
console.log(myEntry.toArray())
// ↑ [ 'Apex', 'Captain' ]
Turns this Entry into a simple JSON object string.
const myEntry = Entry.from(["Apex", "Captain"])
console.log(myEntry.toString()) // Or, you can use console.log(`${myEntry}`)
// ↑ {"keyElement":'Apex',"valueElement":"Captain"}
Static
fromCreate an Entry instance by iterable two values pair.
const myEntry = Entry.from(["Apex", "Captain"])
console.log(myEntry)
// ↑ Entry { keyElement: 'Apex', valueElement: 'Captain' }
Entry pair of key/value as iterable.
Generated using TypeDoc
Represents a key/value pair for KoconutMap. The type of key basically could be any kind of class instance, however it is recommended to be a number, string or custom class that inherits KoconutEquatable. Otherwise, further equality check process in KoconutSet or KoconutMap will not work as intented. This is beacuse even if there are two different instances of same class, which have exactly identical properties, they are fundamentally indistinguishable from each other. Please, check the example of 'equalsTo' method
See