int Multiset::get(int i, ItemType& value) const { if (0 <= i && i < uniqueSize()) { Node* current = _head; for (int j = 0; j < i; j++) //Make current point to the ith item in the linked list { current = current->next; } value = current->data.item; return current->data.count; } return 0; }
int Multiset::get(int i, ItemType& value) const { if (i < 0 || i >= uniqueSize()) return 0; int counter = 0; for (int x = 0; x < DEFAULT_MAX_ITEMS; x++) { if (m_array[x].count != 0) counter++; if (i == counter - 1) { value = m_array[x].value; return m_array[x].count; } } return 0; }