what is the most elegant way to join two Hashtables?
I have this HashTable and I cannot use an Array or List or Set instead, because it messes up dealing with the custom-class. At least that's what I think.
**Hashtable<ItemSet, Integer> frequentItemSetL1 = new Hashtable<>();**
for (Map.Entry<ItemSet, Integer> entry : candidateItemSetC1.entrySet()) {
if (entry.getValue() >= supportThreshold) {
frequentItemSetL1.put(entry.getKey(), entry.getValue());
}
which contains: Key-value-pairs.
- Key = Number of an Itemset
- Value = Number of occurrences of that itemset in the data
Looks like this:
{1}, 3
{2}, 23
{3}, 7
{4}, 18
.....
I need the KEYS of frequentItemSetL1 to join with THEMSELVES;
Result should be:
{1, 2}
{1, 3}
{1, 4}
{2, 3}
{2, 4}
{3, 4}
I experimented with two for-loops and KeySets but did not get far. Could need some fresh ideas.
Tried this:
for (int i = 0; i < frequentItemSetL1.size(); i++) {
Integer item1 = frequentItemSetL1.get(i);
for (int j = i + 1; j < frequentItemSetL1.size(); j++) {
Integer item2 = frequentItemSetL1.get(j);
// Create a new candidate by combining itemset1 and itemset2
candidateItemSetC2.put(item1, item2);
}