You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

proto_ext.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. Map.prototype.setD = function(k,v){
  2. if (!this.has(k)){
  3. this.set(k,v)
  4. // clog("SetD")
  5. return 1
  6. }
  7. // clog("SetD0")
  8. }
  9. Set.prototype.isSuperset = function(subset) {
  10. for (var elem of subset) {
  11. if (!this.has(elem)) {
  12. return false;
  13. }
  14. }
  15. return true;
  16. }
  17. Set.prototype.union = function(setB) {
  18. var union = new Set(this);
  19. for (var elem of setB) {
  20. union.add(elem);
  21. }
  22. return union;
  23. }
  24. Set.prototype.intersection = function(setB) {
  25. var intersection = new Set();
  26. for (var elem of setB) {
  27. if (this.has(elem)) {
  28. intersection.add(elem);
  29. }
  30. }
  31. return intersection;
  32. }
  33. Set.prototype.difference = function(setB) {
  34. var difference = new Set(this);
  35. for (var elem of setB) {
  36. difference.delete(elem);
  37. }
  38. return difference;
  39. }
  40. Set.prototype.union_update = function(setB) {
  41. var union = this;
  42. for (var elem of setB) {
  43. union.add(elem);
  44. }
  45. return union;
  46. }
  47. Set.prototype.intersection_update = function(setB) {
  48. var intersection = this
  49. for (var elem of setB) {
  50. if (!this.has(elem)) {
  51. intersection.delete(elem);
  52. }
  53. }
  54. return intersection;
  55. }
  56. Set.prototype.difference_update = function(setB) {
  57. var difference = this;
  58. for (var elem of setB) {
  59. difference.delete(elem);
  60. }
  61. return difference;
  62. }
  63. /*
  64. Set.prototype.symDifference = function(setB) {
  65. var difference = new Set(this.union(setB));
  66. var intersection = new Set(this.intersection(setB));
  67. for (var elem of intersection) {
  68. difference.delete(elem);
  69. }
  70. return difference;
  71. }
  72. */
  73. console.log("test")