data-structure-typed 1.53.8 → 1.53.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/CONTRIBUTING.md +1 -1
  3. package/dist/cjs/data-structures/base/iterable-entry-base.js +4 -4
  4. package/dist/cjs/data-structures/base/iterable-entry-base.js.map +1 -1
  5. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +36 -17
  6. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +64 -35
  7. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  8. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +12 -8
  9. package/dist/cjs/data-structures/binary-tree/avl-tree.js +19 -6
  10. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  11. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +53 -40
  12. package/dist/cjs/data-structures/binary-tree/binary-tree.js +75 -71
  13. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  14. package/dist/cjs/data-structures/binary-tree/bst.d.ts +35 -30
  15. package/dist/cjs/data-structures/binary-tree/bst.js +54 -40
  16. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +43 -22
  18. package/dist/cjs/data-structures/binary-tree/red-black-tree.js +50 -55
  19. package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +1 -1
  20. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +33 -17
  21. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +62 -36
  22. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  23. package/dist/cjs/data-structures/graph/abstract-graph.js +2 -2
  24. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  25. package/dist/cjs/data-structures/hash/hash-map.d.ts +1 -1
  26. package/dist/cjs/data-structures/hash/hash-map.js +5 -5
  27. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  28. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +10 -10
  29. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +12 -12
  30. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  31. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +10 -10
  32. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +16 -16
  33. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  34. package/dist/cjs/interfaces/binary-tree.d.ts +3 -4
  35. package/dist/cjs/types/data-structures/base/base.d.ts +1 -1
  36. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -3
  37. package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +2 -3
  38. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +2 -3
  39. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +3 -4
  40. package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +4 -5
  41. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +4 -5
  42. package/dist/mjs/data-structures/base/iterable-entry-base.js +4 -4
  43. package/dist/mjs/data-structures/base/iterable-entry-base.js.map +1 -1
  44. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +36 -17
  45. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +64 -35
  46. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  47. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +12 -8
  48. package/dist/mjs/data-structures/binary-tree/avl-tree.js +19 -6
  49. package/dist/mjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  50. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +53 -40
  51. package/dist/mjs/data-structures/binary-tree/binary-tree.js +75 -71
  52. package/dist/mjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  53. package/dist/mjs/data-structures/binary-tree/bst.d.ts +35 -30
  54. package/dist/mjs/data-structures/binary-tree/bst.js +70 -56
  55. package/dist/mjs/data-structures/binary-tree/bst.js.map +1 -1
  56. package/dist/mjs/data-structures/binary-tree/red-black-tree.d.ts +43 -22
  57. package/dist/mjs/data-structures/binary-tree/red-black-tree.js +50 -55
  58. package/dist/mjs/data-structures/binary-tree/red-black-tree.js.map +1 -1
  59. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +33 -17
  60. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +62 -36
  61. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  62. package/dist/mjs/data-structures/graph/abstract-graph.js +2 -2
  63. package/dist/mjs/data-structures/graph/abstract-graph.js.map +1 -1
  64. package/dist/mjs/data-structures/hash/hash-map.d.ts +1 -1
  65. package/dist/mjs/data-structures/hash/hash-map.js +5 -5
  66. package/dist/mjs/data-structures/hash/hash-map.js.map +1 -1
  67. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +10 -10
  68. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +12 -12
  69. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  70. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +10 -10
  71. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +16 -16
  72. package/dist/mjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  73. package/dist/mjs/interfaces/binary-tree.d.ts +3 -4
  74. package/dist/mjs/types/data-structures/base/base.d.ts +1 -1
  75. package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -3
  76. package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +2 -3
  77. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +2 -3
  78. package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +3 -4
  79. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +4 -5
  80. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +4 -5
  81. package/dist/umd/data-structure-typed.js +337 -253
  82. package/dist/umd/data-structure-typed.min.js +3 -3
  83. package/dist/umd/data-structure-typed.min.js.map +1 -1
  84. package/package.json +6 -6
  85. package/src/data-structures/base/iterable-entry-base.ts +4 -4
  86. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +81 -54
  87. package/src/data-structures/binary-tree/avl-tree.ts +32 -15
  88. package/src/data-structures/binary-tree/binary-tree.ts +88 -83
  89. package/src/data-structures/binary-tree/bst.ts +87 -74
  90. package/src/data-structures/binary-tree/red-black-tree.ts +55 -54
  91. package/src/data-structures/binary-tree/tree-multi-map.ts +79 -49
  92. package/src/data-structures/graph/abstract-graph.ts +2 -2
  93. package/src/data-structures/hash/hash-map.ts +7 -7
  94. package/src/data-structures/linked-list/doubly-linked-list.ts +13 -13
  95. package/src/data-structures/linked-list/singly-linked-list.ts +17 -17
  96. package/src/interfaces/binary-tree.ts +3 -13
  97. package/src/types/data-structures/base/base.ts +1 -1
  98. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +2 -4
  99. package/src/types/data-structures/binary-tree/avl-tree.ts +2 -4
  100. package/src/types/data-structures/binary-tree/binary-tree.ts +3 -3
  101. package/src/types/data-structures/binary-tree/bst.ts +3 -5
  102. package/src/types/data-structures/binary-tree/rb-tree.ts +4 -6
  103. package/src/types/data-structures/binary-tree/tree-multi-map.ts +4 -6
  104. package/test/integration/index.html +3 -3
  105. package/test/performance/data-structures/binary-tree/binary-tree-overall.test.ts +3 -3
  106. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +12 -12
  107. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +10 -10
  108. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +10 -10
  109. package/test/unit/data-structures/binary-tree/bst.test.ts +11 -11
  110. package/test/unit/data-structures/binary-tree/data/cost-of-living-by-country.ts +259 -0
  111. package/test/unit/data-structures/binary-tree/overall.test.ts +2 -0
  112. package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +30 -10
  113. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +10 -10
  114. package/test/unit/data-structures/graph/directed-graph.test.ts +4 -4
  115. package/test/unit/data-structures/hash/hash-map.test.ts +12 -12
@@ -0,0 +1,259 @@
1
+ export type CostOfLiving = {
2
+ rank: number;
3
+ country: string;
4
+ 'Meal, Inexpensive Restaurant': number;
5
+ 'Domestic Beer (0.5 liter draught)': number;
6
+ 'Water (0.33 liter bottle)': number;
7
+ 'Milk (regular), (1 liter)': number;
8
+ 'Loaf of Fresh White Bread (500g)': number;
9
+ 'Eggs (regular) (12)': number;
10
+ 'Local Cheese (1kg)': number;
11
+ 'Water (1.5 liter bottle)': number;
12
+ 'One-way Ticket (Local Transport)': number;
13
+ 'Gasoline (1 liter)': number;
14
+ 'Apartment (3 bedrooms) in City Centre': number;
15
+ 'Basic (Electricity, Heating, Cooling, Water, Garbage) for 85m2 Apartment': number;
16
+ 'Internet (60 Mbps or More, Unlimited Data, Cable/ADSL)': number;
17
+ 'Mobile Phone Monthly Plan with Calls and 10GB+ Data': number;
18
+ 'Cinema, International Release, 1 Seat': number;
19
+ '1 Pair of Jeans (Levis 501 Or Similar)': number;
20
+ 'Price per Square Meter to Buy Apartment in City Centre': number;
21
+ 'Average Monthly Net Salary (After Tax)': number;
22
+ 'Mortgage Interest Rate in Percentages (%), Yearly, for 20 Years Fixed-Rate': number;
23
+ 'Taxi 1km (Normal Tariff)': number;
24
+ 'Oranges (1kg)': number;
25
+ 'Potato (1kg)': number;
26
+ 'Lettuce (1 head)': number;
27
+ 'Rice (white), (1kg)': number;
28
+ 'Onion (1kg)': number;
29
+ 'Beef Round (1kg) (or Equivalent Back Leg Red Meat)': number;
30
+ 'Toyota Corolla Sedan 1.6l 97kW Comfort (Or Equivalent New Car)': number;
31
+ 'Preschool (or Kindergarten), Full Day, Private, Monthly for 1 Child': number;
32
+ };
33
+
34
+ export const costOfLiving: CostOfLiving[] = [
35
+ {
36
+ rank: 1,
37
+ country: 'Switzerland',
38
+ 'Meal, Inexpensive Restaurant': 27.98,
39
+ 'Domestic Beer (0.5 liter draught)': 7.83,
40
+ 'Water (0.33 liter bottle)': 4.49,
41
+ 'Milk (regular), (1 liter)': 1.95,
42
+ 'Loaf of Fresh White Bread (500g)': 3.63,
43
+ 'Eggs (regular) (12)': 6.83,
44
+ 'Local Cheese (1kg)': 26.02,
45
+ 'Water (1.5 liter bottle)': 1.13,
46
+ 'One-way Ticket (Local Transport)': 3.92,
47
+ 'Gasoline (1 liter)': 2.06,
48
+ 'Apartment (3 bedrooms) in City Centre': 3359.12,
49
+ 'Basic (Electricity, Heating, Cooling, Water, Garbage) for 85m2 Apartment': 243.82,
50
+ 'Internet (60 Mbps or More, Unlimited Data, Cable/ADSL)': 54.3,
51
+ 'Mobile Phone Monthly Plan with Calls and 10GB+ Data': 51.26,
52
+ 'Cinema, International Release, 1 Seat': 22.38,
53
+ '1 Pair of Jeans (Levis 501 Or Similar)': 120.18,
54
+ 'Price per Square Meter to Buy Apartment in City Centre': 16439.97,
55
+ 'Average Monthly Net Salary (After Tax)': 6628.35,
56
+ 'Mortgage Interest Rate in Percentages (%), Yearly, for 20 Years Fixed-Rate': 2.49,
57
+ 'Taxi 1km (Normal Tariff)': 4.36,
58
+ 'Oranges (1kg)': 2.93,
59
+ 'Potato (1kg)': 2.48,
60
+ 'Lettuce (1 head)': 2.35,
61
+ 'Rice (white), (1kg)': 3.98,
62
+ 'Onion (1kg)': 2.29,
63
+ 'Beef Round (1kg) (or Equivalent Back Leg Red Meat)': 45.89,
64
+ 'Toyota Corolla Sedan 1.6l 97kW Comfort (Or Equivalent New Car)': 37549.18,
65
+ 'Preschool (or Kindergarten), Full Day, Private, Monthly for 1 Child': 2832.82
66
+ },
67
+ {
68
+ rank: 23,
69
+ country: 'New Zealand',
70
+ 'Meal, Inexpensive Restaurant': 14.58,
71
+ 'Domestic Beer (0.5 liter draught)': 6.42,
72
+ 'Water (0.33 liter bottle)': 2.01,
73
+ 'Milk (regular), (1 liter)': 1.76,
74
+ 'Loaf of Fresh White Bread (500g)': 1.87,
75
+ 'Eggs (regular) (12)': 6.32,
76
+ 'Local Cheese (1kg)': 8.02,
77
+ 'Water (1.5 liter bottle)': 1.16,
78
+ 'One-way Ticket (Local Transport)': 2.33,
79
+ 'Gasoline (1 liter)': 1.63,
80
+ 'Apartment (3 bedrooms) in City Centre': 1758.7,
81
+ 'Basic (Electricity, Heating, Cooling, Water, Garbage) for 85m2 Apartment': 135.28,
82
+ 'Internet (60 Mbps or More, Unlimited Data, Cable/ADSL)': 50.44,
83
+ 'Mobile Phone Monthly Plan with Calls and 10GB+ Data': 34.27,
84
+ 'Cinema, International Release, 1 Seat': 11.67,
85
+ '1 Pair of Jeans (Levis 501 Or Similar)': 67.67,
86
+ 'Price per Square Meter to Buy Apartment in City Centre': 5371.0,
87
+ 'Average Monthly Net Salary (After Tax)': 2920.79,
88
+ 'Mortgage Interest Rate in Percentages (%), Yearly, for 20 Years Fixed-Rate': 6.84,
89
+ 'Taxi 1km (Normal Tariff)': 2.01,
90
+ 'Oranges (1kg)': 2.94,
91
+ 'Potato (1kg)': 2.07,
92
+ 'Lettuce (1 head)': 2.35,
93
+ 'Rice (white), (1kg)': 1.82,
94
+ 'Onion (1kg)': 1.77,
95
+ 'Beef Round (1kg) (or Equivalent Back Leg Red Meat)': 12.58,
96
+ 'Toyota Corolla Sedan 1.6l 97kW Comfort (Or Equivalent New Car)': 20980.7,
97
+ 'Preschool (or Kindergarten), Full Day, Private, Monthly for 1 Child': 752.33
98
+ },
99
+ {
100
+ rank: 41,
101
+ country: 'Mexico',
102
+ 'Meal, Inexpensive Restaurant': 9.79,
103
+ 'Domestic Beer (0.5 liter draught)': 2.2,
104
+ 'Water (0.33 liter bottle)': 0.83,
105
+ 'Milk (regular), (1 liter)': 1.35,
106
+ 'Loaf of Fresh White Bread (500g)': 2.36,
107
+ 'Eggs (regular) (12)': 2.16,
108
+ 'Local Cheese (1kg)': 7.87,
109
+ 'Water (1.5 liter bottle)': 0.91,
110
+ 'One-way Ticket (Local Transport)': 0.54,
111
+ 'Gasoline (1 liter)': 1.18,
112
+ 'Apartment (3 bedrooms) in City Centre': 1148.12,
113
+ 'Basic (Electricity, Heating, Cooling, Water, Garbage) for 85m2 Apartment': 59.55,
114
+ 'Internet (60 Mbps or More, Unlimited Data, Cable/ADSL)': 25.94,
115
+ 'Mobile Phone Monthly Plan with Calls and 10GB+ Data': 21.52,
116
+ 'Cinema, International Release, 1 Seat': 4.41,
117
+ '1 Pair of Jeans (Levis 501 Or Similar)': 49.23,
118
+ 'Price per Square Meter to Buy Apartment in City Centre': 1781.03,
119
+ 'Average Monthly Net Salary (After Tax)': 660.35,
120
+ 'Mortgage Interest Rate in Percentages (%), Yearly, for 20 Years Fixed-Rate': 11.43,
121
+ 'Taxi 1km (Normal Tariff)': 1.91,
122
+ 'Oranges (1kg)': 1.61,
123
+ 'Potato (1kg)': 1.81,
124
+ 'Lettuce (1 head)': 1.17,
125
+ 'Rice (white), (1kg)': 1.58,
126
+ 'Onion (1kg)': 1.66,
127
+ 'Beef Round (1kg) (or Equivalent Back Leg Red Meat)': 9.79,
128
+ 'Toyota Corolla Sedan 1.6l 97kW Comfort (Or Equivalent New Car)': 21077.68,
129
+ 'Preschool (or Kindergarten), Full Day, Private, Monthly for 1 Child': 224.39
130
+ },
131
+ {
132
+ rank: 52,
133
+ country: 'South Africa',
134
+ 'Meal, Inexpensive Restaurant': 8.28,
135
+ 'Domestic Beer (0.5 liter draught)': 2.21,
136
+ 'Water (0.33 liter bottle)': 0.73,
137
+ 'Milk (regular), (1 liter)': 1.07,
138
+ 'Loaf of Fresh White Bread (500g)': 0.97,
139
+ 'Eggs (regular) (12)': 2.26,
140
+ 'Local Cheese (1kg)': 7.35,
141
+ 'Water (1.5 liter bottle)': 0.92,
142
+ 'One-way Ticket (Local Transport)': 1.66,
143
+ 'Gasoline (1 liter)': 1.29,
144
+ 'Apartment (3 bedrooms) in City Centre': 892.16,
145
+ 'Basic (Electricity, Heating, Cooling, Water, Garbage) for 85m2 Apartment': 104.63,
146
+ 'Internet (60 Mbps or More, Unlimited Data, Cable/ADSL)': 41.21,
147
+ 'Mobile Phone Monthly Plan with Calls and 10GB+ Data': 31.79,
148
+ 'Cinema, International Release, 1 Seat': 6.62,
149
+ '1 Pair of Jeans (Levis 501 Or Similar)': 47.28,
150
+ 'Price per Square Meter to Buy Apartment in City Centre': 1031.57,
151
+ 'Average Monthly Net Salary (After Tax)': 1383.11,
152
+ 'Mortgage Interest Rate in Percentages (%), Yearly, for 20 Years Fixed-Rate': 11.58,
153
+ 'Taxi 1km (Normal Tariff)': 1.1,
154
+ 'Oranges (1kg)': 1.4,
155
+ 'Potato (1kg)': 1.21,
156
+ 'Lettuce (1 head)': 1.02,
157
+ 'Rice (white), (1kg)': 1.53,
158
+ 'Onion (1kg)': 1.34,
159
+ 'Beef Round (1kg) (or Equivalent Back Leg Red Meat)': 6.55,
160
+ 'Toyota Corolla Sedan 1.6l 97kW Comfort (Or Equivalent New Car)': 23105.93,
161
+ 'Preschool (or Kindergarten), Full Day, Private, Monthly for 1 Child': 193.32
162
+ },
163
+ {
164
+ rank: 65,
165
+ country: 'Japan',
166
+ 'Meal, Inexpensive Restaurant': 6.46,
167
+ 'Domestic Beer (0.5 liter draught)': 3.23,
168
+ 'Water (0.33 liter bottle)': 0.73,
169
+ 'Milk (regular), (1 liter)': 1.4,
170
+ 'Loaf of Fresh White Bread (500g)': 1.46,
171
+ 'Eggs (regular) (12)': 2.08,
172
+ 'Local Cheese (1kg)': 11.12,
173
+ 'Water (1.5 liter bottle)': 0.85,
174
+ 'One-way Ticket (Local Transport)': 1.42,
175
+ 'Gasoline (1 liter)': 1.11,
176
+ 'Apartment (3 bedrooms) in City Centre': 1248.4,
177
+ 'Basic (Electricity, Heating, Cooling, Water, Garbage) for 85m2 Apartment': 166.85,
178
+ 'Internet (60 Mbps or More, Unlimited Data, Cable/ADSL)': 32.64,
179
+ 'Mobile Phone Monthly Plan with Calls and 10GB+ Data': 25.29,
180
+ 'Cinema, International Release, 1 Seat': 12.28,
181
+ '1 Pair of Jeans (Levis 501 Or Similar)': 43.21,
182
+ 'Price per Square Meter to Buy Apartment in City Centre': 6324.16,
183
+ 'Average Monthly Net Salary (After Tax)': 2069.74,
184
+ 'Mortgage Interest Rate in Percentages (%), Yearly, for 20 Years Fixed-Rate': 1.83,
185
+ 'Taxi 1km (Normal Tariff)': 2.91,
186
+ 'Oranges (1kg)': 4.35,
187
+ 'Potato (1kg)': 2.63,
188
+ 'Lettuce (1 head)': 1.26,
189
+ 'Rice (white), (1kg)': 3.72,
190
+ 'Onion (1kg)': 2.39,
191
+ 'Beef Round (1kg) (or Equivalent Back Leg Red Meat)': 16.87,
192
+ 'Toyota Corolla Sedan 1.6l 97kW Comfort (Or Equivalent New Car)': 16534.56,
193
+ 'Preschool (or Kindergarten), Full Day, Private, Monthly for 1 Child': 353.95
194
+ },
195
+ {
196
+ rank: 72,
197
+ country: 'Brazil',
198
+ 'Meal, Inexpensive Restaurant': 5.17,
199
+ 'Domestic Beer (0.5 liter draught)': 1.72,
200
+ 'Water (0.33 liter bottle)': 0.65,
201
+ 'Milk (regular), (1 liter)': 0.93,
202
+ 'Loaf of Fresh White Bread (500g)': 1.43,
203
+ 'Eggs (regular) (12)': 1.92,
204
+ 'Local Cheese (1kg)': 8.08,
205
+ 'Water (1.5 liter bottle)': 0.63,
206
+ 'One-way Ticket (Local Transport)': 0.86,
207
+ 'Gasoline (1 liter)': 0.98,
208
+ 'Apartment (3 bedrooms) in City Centre': 622.9,
209
+ 'Basic (Electricity, Heating, Cooling, Water, Garbage) for 85m2 Apartment': 65.01,
210
+ 'Internet (60 Mbps or More, Unlimited Data, Cable/ADSL)': 18.39,
211
+ 'Mobile Phone Monthly Plan with Calls and 10GB+ Data': 13.92,
212
+ 'Cinema, International Release, 1 Seat': 6.03,
213
+ '1 Pair of Jeans (Levis 501 Or Similar)': 46.84,
214
+ 'Price per Square Meter to Buy Apartment in City Centre': 1513.42,
215
+ 'Average Monthly Net Salary (After Tax)': 417.56,
216
+ 'Mortgage Interest Rate in Percentages (%), Yearly, for 20 Years Fixed-Rate': 10.98,
217
+ 'Taxi 1km (Normal Tariff)': 0.83,
218
+ 'Oranges (1kg)': 1.04,
219
+ 'Potato (1kg)': 1.11,
220
+ 'Lettuce (1 head)': 0.68,
221
+ 'Rice (white), (1kg)': 1.11,
222
+ 'Onion (1kg)': 1.06,
223
+ 'Beef Round (1kg) (or Equivalent Back Leg Red Meat)': 6.93,
224
+ 'Toyota Corolla Sedan 1.6l 97kW Comfort (Or Equivalent New Car)': 26186.46,
225
+ 'Preschool (or Kindergarten), Full Day, Private, Monthly for 1 Child': 279.87
226
+ },
227
+ {
228
+ rank: 74,
229
+ country: 'Taiwan',
230
+ 'Meal, Inexpensive Restaurant': 4.6,
231
+ 'Domestic Beer (0.5 liter draught)': 1.84,
232
+ 'Water (0.33 liter bottle)': 0.65,
233
+ 'Milk (regular), (1 liter)': 2.99,
234
+ 'Loaf of Fresh White Bread (500g)': 1.84,
235
+ 'Eggs (regular) (12)': 2.75,
236
+ 'Local Cheese (1kg)': 15.19,
237
+ 'Water (1.5 liter bottle)': 1.14,
238
+ 'One-way Ticket (Local Transport)': 0.77,
239
+ 'Gasoline (1 liter)': 0.95,
240
+ 'Apartment (3 bedrooms) in City Centre': 1124.03,
241
+ 'Basic (Electricity, Heating, Cooling, Water, Garbage) for 85m2 Apartment': 78.3,
242
+ 'Internet (60 Mbps or More, Unlimited Data, Cable/ADSL)': 21.65,
243
+ 'Mobile Phone Monthly Plan with Calls and 10GB+ Data': 22.18,
244
+ 'Cinema, International Release, 1 Seat': 9.51,
245
+ '1 Pair of Jeans (Levis 501 Or Similar)': 63.34,
246
+ 'Price per Square Meter to Buy Apartment in City Centre': 8859.94,
247
+ 'Average Monthly Net Salary (After Tax)': 1654.66,
248
+ 'Mortgage Interest Rate in Percentages (%), Yearly, for 20 Years Fixed-Rate': 2.0,
249
+ 'Taxi 1km (Normal Tariff)': 0.77,
250
+ 'Oranges (1kg)': 2.64,
251
+ 'Potato (1kg)': 2.61,
252
+ 'Lettuce (1 head)': 1.82,
253
+ 'Rice (white), (1kg)': 2.97,
254
+ 'Onion (1kg)': 2.15,
255
+ 'Beef Round (1kg) (or Equivalent Back Leg Red Meat)': 18.14,
256
+ 'Toyota Corolla Sedan 1.6l 97kW Comfort (Or Equivalent New Car)': 24143.1,
257
+ 'Preschool (or Kindergarten), Full Day, Private, Monthly for 1 Child': 508.49
258
+ }
259
+ ];
@@ -82,7 +82,9 @@ describe('Overall BinaryTree Test', () => {
82
82
  expect(bst.has(9)).toBe(true);
83
83
  expect(bst.has(7)).toBe(false);
84
84
  expect(bst.bfs()).toEqual([6, 9, 3, 1]);
85
+
85
86
  const clonedBST = bst.clone();
87
+
86
88
  expect(clonedBST.size).toBe(4);
87
89
  expect(clonedBST.root?.key).toBe(6);
88
90
  expect(clonedBST.root?.left?.key).toBe(9);
@@ -3,6 +3,7 @@ import { getRandomInt, getRandomIntArray, magnitude } from '../../../utils';
3
3
  import { OrderedMap } from 'js-sdsl';
4
4
 
5
5
  import { isDebugTest } from '../../../config';
6
+ import { costOfLiving } from './data/cost-of-living-by-country';
6
7
 
7
8
  const isDebug = isDebugTest;
8
9
  // const isDebug = true;
@@ -647,18 +648,18 @@ describe('RedBlackTree 2', () => {
647
648
 
648
649
  it('forEach should iterate over all elements', () => {
649
650
  const mockCallback = jest.fn();
650
- rbTree.forEach((value, key) => {
651
- mockCallback(value, key);
651
+ rbTree.forEach((key, value) => {
652
+ mockCallback(key, value);
652
653
  });
653
654
 
654
655
  expect(mockCallback.mock.calls.length).toBe(3);
655
- expect(mockCallback.mock.calls[0]).toEqual(['a', 1]);
656
- expect(mockCallback.mock.calls[1]).toEqual(['b', 2]);
657
- expect(mockCallback.mock.calls[2]).toEqual(['c', 3]);
656
+ expect(mockCallback.mock.calls[0]).toEqual([1, 'a']);
657
+ expect(mockCallback.mock.calls[1]).toEqual([2, 'b']);
658
+ expect(mockCallback.mock.calls[2]).toEqual([3, 'c']);
658
659
  });
659
660
 
660
661
  it('filter should return a new rbTree with filtered elements', () => {
661
- const filteredTree = rbTree.filter((value, key) => key > 1);
662
+ const filteredTree = rbTree.filter(key => key > 1);
662
663
  expect(filteredTree.size).toBe(2);
663
664
  expect([...filteredTree]).toEqual([
664
665
  [2, 'b'],
@@ -667,12 +668,12 @@ describe('RedBlackTree 2', () => {
667
668
  });
668
669
 
669
670
  it('map should return a new rbTree with modified elements', () => {
670
- const mappedTree = rbTree.map((value, key) => (key * 2).toString());
671
+ const mappedTree = rbTree.map((key, value) => [(key * 2).toString(), value]);
671
672
  expect(mappedTree.size).toBe(3);
672
673
  expect([...mappedTree]).toEqual([
673
- [1, '2'],
674
- [2, '4'],
675
- [3, '6']
674
+ ['2', 'a'],
675
+ ['4', 'b'],
676
+ ['6', 'c']
676
677
  ]);
677
678
  });
678
679
 
@@ -820,6 +821,25 @@ describe('RedBlackTree - _deleteFixup', () => {
820
821
  });
821
822
  });
822
823
 
824
+ describe('real world data', () => {
825
+ it('cost of living', () => {
826
+ const indexedByRank = new RedBlackTree(costOfLiving, {
827
+ specifyComparable: node => node.rank,
828
+ toEntryFn: raw => [raw, undefined]
829
+ });
830
+ expect(indexedByRank.size).toBe(7);
831
+ expect(indexedByRank.dfs(node => node?.key?.country)).toEqual([
832
+ 'Switzerland',
833
+ 'New Zealand',
834
+ 'Mexico',
835
+ 'South Africa',
836
+ 'Japan',
837
+ 'Brazil',
838
+ 'Taiwan'
839
+ ]);
840
+ });
841
+ });
842
+
823
843
  describe('classic use', () => {
824
844
  // Test case for finding elements in a given range
825
845
  it('@example Find elements in a range', () => {
@@ -764,18 +764,18 @@ describe('TreeMultiMap iterative methods test', () => {
764
764
 
765
765
  it('forEach should iterate over all elements', () => {
766
766
  const mockCallback = jest.fn();
767
- treeMM.forEach((value, key) => {
768
- mockCallback(value, key);
767
+ treeMM.forEach((key, value) => {
768
+ mockCallback(key, value);
769
769
  });
770
770
 
771
771
  expect(mockCallback.mock.calls.length).toBe(3);
772
- expect(mockCallback.mock.calls[0]).toEqual(['a', 1]);
773
- expect(mockCallback.mock.calls[1]).toEqual(['b', 2]);
774
- expect(mockCallback.mock.calls[2]).toEqual(['c', 3]);
772
+ expect(mockCallback.mock.calls[0]).toEqual([1, 'a']);
773
+ expect(mockCallback.mock.calls[1]).toEqual([2, 'b']);
774
+ expect(mockCallback.mock.calls[2]).toEqual([3, 'c']);
775
775
  });
776
776
 
777
777
  it('filter should return a new tree with filtered elements', () => {
778
- const filteredTree = treeMM.filter((value, key) => key > 1);
778
+ const filteredTree = treeMM.filter(key => key > 1);
779
779
  expect(filteredTree.size).toBe(2);
780
780
  expect([...filteredTree]).toEqual([
781
781
  [2, 'b'],
@@ -784,12 +784,12 @@ describe('TreeMultiMap iterative methods test', () => {
784
784
  });
785
785
 
786
786
  it('map should return a new tree with modified elements', () => {
787
- const mappedTree = treeMM.map((value, key) => (key * 2).toString());
787
+ const mappedTree = treeMM.map((key, value) => [(key * 2).toString(), value]);
788
788
  expect(mappedTree.size).toBe(3);
789
789
  expect([...mappedTree]).toEqual([
790
- [1, '2'],
791
- [2, '4'],
792
- [3, '6']
790
+ ['2', 'a'],
791
+ ['4', 'b'],
792
+ ['6', 'c']
793
793
  ]);
794
794
  });
795
795
 
@@ -680,12 +680,12 @@ describe('DirectedGraph iterative Methods', () => {
680
680
 
681
681
  it('forEach should apply a function to each vertex', () => {
682
682
  const result: VertexKey[] = [];
683
- graph.forEach((value, key) => key && result.push(key));
683
+ graph.forEach(key => key && result.push(key));
684
684
  expect(result).toEqual(vertexMap);
685
685
  });
686
686
 
687
687
  it('filter should return vertexMap that satisfy the condition', () => {
688
- const filtered = graph.filter((value, vertex) => vertex === 'A' || vertex === 'B');
688
+ const filtered = graph.filter(vertex => vertex === 'A' || vertex === 'B');
689
689
  expect(filtered).toEqual([
690
690
  ['A', undefined],
691
691
  ['B', undefined]
@@ -693,8 +693,8 @@ describe('DirectedGraph iterative Methods', () => {
693
693
  });
694
694
 
695
695
  it('map should apply a function to each vertex and return a new array', () => {
696
- const mapped = graph.map((value, vertex) => vertex + '_mapped');
697
- expect(mapped).toEqual(vertexMap.map(v => v + '_mapped'));
696
+ const mapped = graph.map(vertex => vertex + '_mapped');
697
+ expect(mapped).toEqual(vertexMap.map(key => key + '_mapped'));
698
698
  });
699
699
 
700
700
  it('reduce should accumulate a value based on each vertex', () => {
@@ -328,7 +328,7 @@ describe('HashMap', () => {
328
328
  });
329
329
 
330
330
  it('some() returns true if any element matches the condition', () => {
331
- expect(hashMap.some((value, key) => key === 'key1')).toBe(true);
331
+ expect(hashMap.some(key => key === 'key1')).toBe(true);
332
332
  });
333
333
 
334
334
  it('forEach() should execute a function for each element', () => {
@@ -338,12 +338,12 @@ describe('HashMap', () => {
338
338
  });
339
339
 
340
340
  it('map() should transform each element', () => {
341
- const newHashMap = hashMap.map(value => value.toUpperCase());
341
+ const newHashMap = hashMap.map((key, value) => value.toUpperCase());
342
342
  expect(newHashMap.get('key1')).toBe('VALUE1');
343
343
  });
344
344
 
345
345
  it('filter() should remove elements that do not match the condition', () => {
346
- const filteredHashMap = hashMap.filter((value, key) => key !== 'key1');
346
+ const filteredHashMap = hashMap.filter((key, value) => key !== 'key1');
347
347
  expect(filteredHashMap.has('key1')).toBe(false);
348
348
  });
349
349
 
@@ -361,28 +361,28 @@ describe('HashMap', () => {
361
361
  });
362
362
 
363
363
  it('should find', () => {
364
- const found = hashMap.find(value => value === 'value1');
364
+ const found = hashMap.find((key, value) => value === 'value1');
365
365
  expect(found).toEqual(['key1', 'value1']);
366
366
  const notFound = hashMap.find(value => value === 'value6');
367
367
  expect(notFound).toEqual(undefined);
368
368
  });
369
369
 
370
370
  it('should every', () => {
371
- const isEvery = hashMap.every(value => value.substring(0, 5) === 'value');
371
+ const isEvery = hashMap.every((key, value) => value.substring(0, 5) === 'value');
372
372
  expect(isEvery).toEqual(true);
373
- const isEvery4 = hashMap.every(value => value.substring(0, 4) === 'value');
373
+ const isEvery4 = hashMap.every((key, value) => value.substring(0, 4) === 'value');
374
374
  expect(isEvery4).toEqual(false);
375
375
  });
376
376
 
377
377
  it('should some', () => {
378
- const isSome = hashMap.some(value => value.substring(5, 6) === '2');
378
+ const isSome = hashMap.some((key, value) => value.substring(5, 6) === '2');
379
379
  expect(isSome).toEqual(true);
380
- const isSome4 = hashMap.some(value => value.substring(0, 5) === 'value');
380
+ const isSome4 = hashMap.some((key, value) => value.substring(0, 5) === 'value');
381
381
  expect(isSome4).toEqual(true);
382
382
  });
383
383
 
384
384
  it('should forEach', () => {
385
- hashMap.forEach((value, key, index) => expect(value.substring(5, 6)).toBe(String(index + 1)));
385
+ hashMap.forEach((key, value, index) => expect(value.substring(5, 6)).toBe(String(index + 1)));
386
386
  });
387
387
 
388
388
  it('should entries', () => {
@@ -817,7 +817,7 @@ describe('LinkedHashMap', () => {
817
817
  });
818
818
 
819
819
  it('some() returns true if any element matches the condition', () => {
820
- expect(hashMap.some((value, key) => key === 'key1')).toBe(true);
820
+ expect(hashMap.some(key => key === 'key1')).toBe(true);
821
821
  });
822
822
 
823
823
  it('forEach() should execute a function for each element', () => {
@@ -827,12 +827,12 @@ describe('LinkedHashMap', () => {
827
827
  });
828
828
 
829
829
  it('map() should transform each element', () => {
830
- const newHashMap = hashMap.map(value => value.toUpperCase());
830
+ const newHashMap = hashMap.map((key, value) => [key, value.toUpperCase()]);
831
831
  expect(newHashMap.get('key1')).toBe('VALUE1');
832
832
  });
833
833
 
834
834
  it('filter() should remove elements that do not match the condition', () => {
835
- const filteredHashMap = hashMap.filter((value, key) => key !== 'key1');
835
+ const filteredHashMap = hashMap.filter(key => key !== 'key1');
836
836
  expect(filteredHashMap.has('key1')).toBe(false);
837
837
  });
838
838