You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// if (mySet.contains(objD)){ // checking for value equality
// console.log('found');
// }
// size is returning wrong value
mySet.remove(objA);
mySet.remove(objB);
mySet.remove(objC);
mySet.remove(objD);
console.log(mySet.size());
}
The text was updated successfully, but these errors were encountered:
janand1977
changed the title
Set function size call does not return the correct size and returns either 1 or 0
Set type: size call does not return the correct size and returns either 1 or 0
Oct 2, 2024
import { Heap,Set, Dictionary } from 'typescript-collections';
import * as Collections from 'typescript-collections';
class Emp {
constructor(public sal: number, public id: string) {}
valueOf() {
return this.sal;
}
toString() {
Collections.util.makeString(this);
}
}
const useSet =() => {
let objA = new Emp(109, 'adn');
let objB = new Emp(110, 'adn');
let objC = new Emp(106, 'adn');
let objD = new Emp(106, 'adn');
let mySet:Set = new Set();
mySet.add(objA);
mySet.add(objB);
mySet.add(objC);
mySet.add(objD);
console.log(mySet.contains(objA));
console.log(mySet.size());
// if (mySet.contains(objD)){ // checking for value equality
// console.log('found');
// }
// size is returning wrong value
mySet.remove(objA);
mySet.remove(objB);
mySet.remove(objC);
mySet.remove(objD);
console.log(mySet.size());
}
The text was updated successfully, but these errors were encountered: