aboutsummaryrefslogtreecommitdiff
path: root/PDContainer/src/HMultiMap.cpp
blob: ecc482e73135c89cdc0610796e30e233be21656b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// *********************(c)*2004*********************>
// -holzilib--holzilib--holzilib--holzilib--holzilib->
// ++++PD-External++by+Georg+Holzmann++grh@gmx.at++++>
//
// PDContainer: 
// this is a port of the containers from the C++ STL
// (Standard Template Library)
// for usage see the documentation and PD help files
// for license see readme.txt
//
// HMultiMap.cpp


#include "include/HMultiMap.h"


//---------------------------------------------------
/* Get a value from the specific Key with the index number
 * index starts with 0
 * returns an element wich points to 0 if nothing was found !!!
 */
Element &HMultiMap::get(Element &key, int index) const
{
  int count = 0;

  for (multimap<Element,Element>::iterator it = data_[h_namespace_].begin();
       it != data_[h_namespace_].end(); ++it)
    {
      if ((*it).first == key)
	{
	  if(index == count++)
	    return ((*it).second);
	}
    }

  // throw an exception if nothing was found
  throw "h_multimap, get: Element not found !";
}