# source:cpp/frams/util/multimap.h@304

Last change on this file since 304 was 304, checked in by Maciej Komosinski, 7 years ago

Improved docs

• Property svn:eol-style set to `native`
File size: 2.4 KB
Line
1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
4
5#ifndef _MULTIMAP_H_
6#define _MULTIMAP_H_
7
8#include "multirange.h"
9
10class SingleMapping
11{
12  public:
13SingleMapping(int b,const MultiRange& t):begin(b),to(t) {}
14SingleMapping(int b):begin(b) {}
15SingleMapping(const SingleMapping& sm):begin(sm.begin),to(sm.to) {}
16int begin;
17MultiRange to;
18};
19
20/** MultiMap - used for conversion mapping.
22    see @ref convmap
23*/
24class MultiMap
25{
26/** list of (SingleMapping*) */
27SList data;
28
29SingleMapping* getData(int i) const {return (SingleMapping*)data(i);}
31void removeData(int i) {data.remove(i);}
32int findData(int x) const;
33int getBegin(int i) const {return getData(i)->begin;}
34
35// addRangeXXX return the shift for range numbers > r
37// value of 'r' is adjusted according to its range number change
38int addRangeBeginEnd(int &r,int begin,int end,const MultiRange& mr);
39
40  public:
41MultiMap() {}
42MultiMap(const MultiMap& mm) {operator=(mm);}
43~MultiMap();
44void operator=(const MultiMap& mm);
45
46void clear();
47int isEmpty() const {return data.size()==0;}
48int mappingCount() const {return data.size();}
49SingleMapping* getMapping(int i) const {return (SingleMapping*)getData(i);}
50int findMappingId(int x) const {return findData(x);}
51int rangeCount() const {return isEmpty()?0:data.size()-1;}
52IRange getRange(int i) const;
53
54int getBegin() const;
55int getEnd() const;
56
60void add(int from1,int from2,const MultiRange& to);
61void add(const MultiRange& from,const MultiRange& to);
63void addCombined(const MultiMap& m1,const MultiMap& m2);