Homework 4 Multisetcpp

Homework 4 Multisetcpp - / Multiset.cpp #include...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
// Multiset.cpp #include "Multiset.h" #include <algorithm> // for std::swap template Multiset::Multiset() { createEmpty(); } { Node* p = find(value); // Inserting a new node at the tail rather than anywhere else // is an arbitrary choice. if (p == m_head) // not found insertAtTail(value, 1); else // found p->m_count++; return true; } { return doErase(value, false); } { return doErase(value, true); } { Node* p = find(value); return p == m_head ? 0 : p->m_count; } int Multiset::get(int i, ItemType& value) const
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
{ if (i < 0 || i >= m_size) return 0; // Return the value at position i. This is one way of ensuring the // required behavior of get: If the Multiset doesn't change in the // interim, // * calling get with each i in 0 <= i < size() gets each of the // Multiset elements, and // * calling get with the same value of i each time gets the same element. // If i is closer to the head of the list, go forward
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/07/2009 for the course CS 32 taught by Professor Davidsmallberg during the Spring '08 term at UCLA.

Page1 / 6

Homework 4 Multisetcpp - / Multiset.cpp #include...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online