Index: cpp/frams/util/list.h
===================================================================
--- cpp/frams/util/list.h	(revision 732)
+++ cpp/frams/util/list.h	(revision 733)
@@ -16,18 +16,18 @@
 class SListStats
 {
-  public:
-int objects, allocations, copied, totalmem, usedmem;
-SListStats():objects(0),allocations(0),copied(0),totalmem(0),usedmem() {}
-~SListStats()
+public:
+	int objects, allocations, copied, totalmem, usedmem;
+	SListStats():objects(0),allocations(0),copied(0),totalmem(0),usedmem() {}
+	~SListStats()
 	{
-	printf("------------------------\n"
-	       " SListStats:\n"
-	       " objects     = %ld\n"
-	       " allocations = %ld\n"
-	       " copied      = %ld\n"
-	       " total mem   = %ld\n"
-	       " usage       = %ld %%\n"
-	       "------------------------\n",
-	       objects,allocations,copied,totalmem,(usedmem*100)/totalmem);
+		printf("------------------------\n"
+			" SListStats:\n"
+			" objects     = %ld\n"
+			" allocations = %ld\n"
+			" copied      = %ld\n"
+			" total mem   = %ld\n"
+			" usage       = %ld %%\n"
+			"------------------------\n",
+			objects,allocations,copied,totalmem,(usedmem*100)/totalmem);
 	}
 };
@@ -38,107 +38,127 @@
 {
 protected:
-int have,used,pos; // ile,zaj,poz
-T *mem;
-void resize(int x)
+	int have, used, pos; // ile,zaj,poz
+	T *mem;
+	void resize(int x)
 	{
-	if (mem || x)
+		if (mem || x)
 		{
-		mem=(T*)realloc(mem,x*sizeof(T));
+			mem = (T*)realloc(mem, x*sizeof(T));
 #ifdef SLISTSTATS
-		SListStats::stats.allocations++;
-		SListStats::stats.copied+=sizeof(T)*min(x,have);
+			SListStats::stats.allocations++;
+			SListStats::stats.copied+=sizeof(T)*min(x,have);
 #endif	
 		}
-	have=x;
+		have = x;
 	}
 
 public:
 
-SListTempl(const SListTempl<T>& src):have(0),used(0),pos(0),mem(0)
-	{(*this)=src;}
-SListTempl():have(0),used(0),pos(0),mem(0)
+	SListTempl(const SListTempl<T>& src) :have(0), used(0), pos(0), mem(0)
+	{
+		(*this) = src;
+	}
+	SListTempl() :have(0), used(0), pos(0), mem(0)
 	{}
-~SListTempl()
+	~SListTempl()
 	{
 #ifdef SLISTSTATS
-	SListStats::stats.objects++;
-	SListStats::stats.totalmem+=sizeof(T)*have;
-	SListStats::stats.usedmem+=sizeof(T)*used;
+		SListStats::stats.objects++;
+		SListStats::stats.totalmem+=sizeof(T)*have;
+		SListStats::stats.usedmem+=sizeof(T)*used;
 #endif
-	hardclear();
+		hardclear();
 	}
 
-void needSize(int s)
-	{ if (s>have) resize(s+3+s/8); }
-void operator+=(const T& e) ///< append one element
- {append(e);}
-void operator-=(const T& e) ///< remove one element
- {int i; if ((i=find(e))>=0) remove(i);}
-void remove(int i,int n=1) ///< remove n elements from position i
+	void needSize(int s)
 	{
-	if ((i>=size())||(i<0)) return;
-	if (i>(size()-n)) n=size()-i;
-	if (pos>=i) pos-=n;
-	memmove(mem+i,mem+i+n,sizeof(T)*(used-n-i));
-	used-=n;
+		if (s > have) resize(s + 3 + s / 8);
 	}
-void operator-=(int i) {remove(i);} ///< remove element from position i
-T& operator()(int i) const ///< return element at position i
-	{return mem[i];}
-bool hasMore() {return pos<size();}
-int operator==(const SListTempl<T>& l) const ///< compare list
- {
- if (size() != l.size()) return 0;
- for (int i=0;i<size();i++) if (l.mem[i] != mem[i]) return 0;
- return 1;
- }
-int find(const T& e) const ///< return position of element, or -1 if not found
-	{ for (int i=0;i<size();i++) if (mem[i]==e) return i;   return -1; }
-void append(const T& data) ///< add 1 element
-	{needSize(size()+1); mem[used++]=data;}
-void append(const T* data,int n) ///< add n elements
+	void operator+=(const T& e) ///< append one element
 	{
-	needSize(size()+n);
-	memcpy(mem+used,data,sizeof(T)*n);
-	used+=n;
+		append(e);
 	}
-void insert(int p,T* data,int n) ///< insert n elements at position p
+	void operator-=(const T& e) ///< remove one element
 	{
-	if (p>size()) p=size();
-	needSize(size()+n);
-	memmove(mem+p+n,mem+p,sizeof(T)*(size()-p));
-	memcpy(mem+p,data,sizeof(T)*n);
-	if (pos>p) pos+=n;
+		int i; if ((i = find(e)) >= 0) remove(i);
 	}
-void insert(int p,const T& data) ///< insert 1 element at position p
+	void remove(int i, int n = 1) ///< remove n elements from position i
 	{
-	if (p>size()) p=size();
-	needSize(size()+1);
-	memmove(mem+p+1,mem+p,sizeof(T)*(size()-p));
-	if (pos>p) pos++;
-	mem[p]=data;
-	used++;
+		if ((i >= size()) || (i<0)) return;
+		if (i>(size() - n)) n = size() - i;
+		if (pos >= i) pos -= n;
+		memmove(mem + i, mem + i + n, sizeof(T)*(used - n - i));
+		used -= n;
 	}
-void set(int p,const T& d)
-	{ needSize(p+1); mem[p]=d; if (used<(p+1)) used=p+1;}
-void setSize(int s)
-	{ needSize(s); used=s;}
-T& get(int i) const {return operator()(i);}
-void clear() {used=0;} ///< remove all elements
-void hardclear() {resize(0); used=0;} ///< remove all elements and free mem
-int size() const {return used;} ///< list size 
-void operator=(const SListTempl<T>&src) ///duplicate
- {
- setSize(src.size());
- memcpy(mem, src.mem, src.size()*sizeof(T));
- }
-void operator+=(const SListTempl<T>&src) ///< append src contents
- {
- needSize(size()+src.size());
- memcpy(mem+used, src.mem, src.size()*sizeof(T));
- used+=src.used;
- }
-void trim(int newsiz)
-	{if (newsiz<used) used=newsiz;}
+	void operator-=(int i) { remove(i); } ///< remove element from position i
+	T& operator()(int i) const ///< return element at position i
+	{
+		return mem[i];
+	}
+	bool hasMore() { return pos < size(); }
+	int operator==(const SListTempl<T>& l) const ///< compare list
+	{
+		if (size() != l.size()) return 0;
+		for (int i = 0; i<size(); i++) if (l.mem[i] != mem[i]) return 0;
+		return 1;
+	}
+	int find(const T& e) const ///< return position of element, or -1 if not found
+	{
+		for (int i = 0; i<size(); i++) if (mem[i] == e) return i;   return -1;
+	}
+	void append(const T& data) ///< add 1 element
+	{
+		needSize(size() + 1); mem[used++] = data;
+	}
+	void append(const T* data, int n) ///< add n elements
+	{
+		needSize(size() + n);
+		memcpy(mem + used, data, sizeof(T)*n);
+		used += n;
+	}
+	void insert(int p, T* data, int n) ///< insert n elements at position p
+	{
+		if (p>size()) p = size();
+		needSize(size() + n);
+		memmove(mem + p + n, mem + p, sizeof(T)*(size() - p));
+		memcpy(mem + p, data, sizeof(T)*n);
+		if (pos > p) pos += n;
+	}
+	void insert(int p, const T& data) ///< insert 1 element at position p
+	{
+		if (p > size()) p = size();
+		needSize(size() + 1);
+		memmove(mem + p + 1, mem + p, sizeof(T)*(size() - p));
+		if (pos > p) pos++;
+		mem[p] = data;
+		used++;
+	}
+	void set(int p, const T& d)
+	{
+		needSize(p + 1); mem[p] = d; if (used < (p + 1)) used = p + 1;
+	}
+	void setSize(int s)
+	{
+		needSize(s); used = s;
+	}
+	T& get(int i) const { return operator()(i); }
+	void clear() { used = 0; } ///< remove all elements
+	void hardclear() { resize(0); used = 0; } ///< remove all elements and free mem
+	int size() const { return used; } ///< list size 
+	void operator=(const SListTempl<T>&src) ///duplicate
+	{
+		setSize(src.size());
+		memcpy(mem, src.mem, src.size()*sizeof(T));
+	}
+	void operator+=(const SListTempl<T>&src) ///< append src contents
+	{
+		needSize(size() + src.size());
+		memcpy(mem + used, src.mem, src.size()*sizeof(T));
+		used += src.used;
+	}
+	void trim(int newsiz)
+	{
+		if (newsiz < used) used = newsiz;
+	}
 };
 
@@ -148,16 +168,18 @@
 // usage example: FOREACH(char*,t,thelist) printf("t=%s\n",t);
 
-template<class T> class PtrListTempl: public SListTempl<T>
+template<class T> class PtrListTempl : public SListTempl < T >
 {
-   public:
-T operator()(int i) const ///< return element at position i
-     {if (i>=this->size()) return 0; else return this->mem[i];}
+public:
+	T operator()(int i) const ///< return element at position i
+	{
+		if (i >= this->size()) return 0; else return this->mem[i];
+	}
 
-T get(int i) const {return operator()(i);}
-T& getref(int i) const {return SListTempl<T>::get(i);}
+	T get(int i) const { return operator()(i); }
+	T& getref(int i) const { return SListTempl<T>::get(i); }
 };
 
 
-typedef PtrListTempl<void*> SList;
+	typedef PtrListTempl<void*> SList;
 
 #endif
Index: cpp/frams/util/multimap.cpp
===================================================================
--- cpp/frams/util/multimap.cpp	(revision 732)
+++ cpp/frams/util/multimap.cpp	(revision 733)
@@ -8,283 +8,285 @@
 int MultiMap::getBegin() const
 {
-if (isEmpty()) return 0;
-return getBegin(0);
+	if (isEmpty()) return 0;
+	return getBegin(0);
 }
 
 int MultiMap::getEnd() const
 {
-if (isEmpty()) return -1;
-return getBegin(mappingCount()-1)-1;
+	if (isEmpty()) return -1;
+	return getBegin(mappingCount() - 1) - 1;
 }
 
 int MultiMap::findData(int x) const
 {
-if (isEmpty()) return -1;
-if (getBegin(0)>x) return -1;
-int a,b,c;
-int n=mappingCount()-1;
-a=0; b=n; // find c = last range with begin<=x
-while(1){
-	c=(a+b+1)/2;
-	if (getBegin(c)<=x)
+	if (isEmpty()) return -1;
+	if (getBegin(0) > x) return -1;
+	int a, b, c;
+	int n = mappingCount() - 1;
+	a = 0; b = n; // find c = last range with begin<=x
+	while (1){
+		c = (a + b + 1) / 2;
+		if (getBegin(c) <= x)
 		{
-		if ((c==n)||(getBegin(c+1)>x)) return c;
-		a=c;
-		}
+			if ((c == n) || (getBegin(c + 1) > x)) return c;
+			a = c;
+		}
+		else
+		{
+			b = c - 1;
+		}
+	}
+}
+
+int MultiMap::addRange(int &r, const MultiRange& mr)
+{
+	// precondition: 0 <= r < (mappingCount()-1)
+	// 1.maybe change mapping in this range
+	int ret = 0;
+	SingleMapping *sm = getMapping(r);
+	if (sm->to.contains(mr)) return 0; // do nothing
+	sm->to.add(mr);
+	// after adding mr to this mapping it could be the same as the previous/next one
+	if (r > 0) // prev exists
+	{
+		SingleMapping *prev = getMapping(r - 1);
+		if (prev->to == sm->to)
+		{ // splice with prev
+			removeData(r);
+			delete sm;
+			sm = prev;
+			r--;
+			ret--;
+		}
+	}
+	if (r < (mappingCount() - 2)) // next exists
+	{
+		SingleMapping *next = getMapping(r + 1);
+		if (next->to == sm->to)
+		{ // splice with next
+			removeData(r + 1);
+			delete next;
+			ret--;
+			r--;
+		}
+	}
+	return ret;
+}
+
+int MultiMap::addRangeBeginEnd(int &r, int begin, int end, const MultiRange& mr)
+{
+	// precondition: -1 <= r < mappingCount()
+	//               begin <= end
+	//               begin >= mapping.begin
+	//               end < nextmapping.begin
+	SingleMapping *m, *m2, *m1;
+	if (r < 0)
+	{
+		if (mappingCount())
+		{
+			m = getMapping(0);
+			if (end == (m->begin - 1))
+			{ // adjacent to m
+				if (m->to == mr)
+				{ // shift only
+					m->begin = begin;
+					return 0;
+				}
+				// single add
+				SingleMapping *newmap = new SingleMapping(begin, mr);
+				addData(0, newmap);
+				r = 0;
+				return 1;
+			}
+		}
+		// double add
+		SingleMapping *newmap = new SingleMapping(begin, mr);
+		SingleMapping *newmap2 = new SingleMapping(end + 1);
+		addData(0, newmap);
+		addData(1, newmap2);
+		r = 1;
+		return 2;
+	}
+
+	if (r == (mappingCount() - 1))
+	{
+		m = getMapping(r);
+		m1 = getMapping(r - 1);
+		if (begin == m->begin)
+		{ // adjacent
+			if (m1->to == mr)
+			{ // shift only
+				m->begin = end + 1;
+				return 0;
+			}
+			// single add
+			m->begin = end + 1;
+			SingleMapping *newmap = new SingleMapping(begin, mr);
+			addData(r, newmap);
+			return 1;
+		}
+		// double add
+		SingleMapping *newmap = new SingleMapping(begin, mr);
+		SingleMapping *newmap2 = new SingleMapping(end + 1);
+		addData(r + 1, newmap);
+		addData(r + 2, newmap2);
+		r += 2;
+		return 2;
+	}
+
+	m = getMapping(r);
+	if (m->to.contains(mr)) return 0;
+	if (begin == m->begin) // begin at range boundary
+	{
+		m2 = getMapping(r + 1);
+		if (end == (m2->begin - 1)) return addRange(r, mr);
+
+		SingleMapping *newmap = new SingleMapping(begin, m->to);
+		newmap->to.add(mr);
+		if (r > 0)
+		{ // join prev possible...
+			m1 = getMapping(r - 1);
+			if (m1->to == newmap->to)
+			{ // joint prev = shift
+				delete newmap;
+				m->begin = end + 1;
+				return 0;
+			}
+		}
+		// single add:
+		m->begin = end + 1;
+		addData(r, newmap);
+		return 1;
+	}
+
+	m2 = getMapping(r + 1);
+	if (end == (m2->begin - 1)) // end at range boundary
+	{
+		SingleMapping *newmap = new SingleMapping(begin, m->to);
+		newmap->to.add(mr);
+		if (r < (mappingCount() - 2))
+		{ // join next possible...
+			if (m2->to == newmap->to)
+			{ // joint next = shift
+				m2->begin = begin;
+				delete newmap;
+				return 0;
+			}
+		}
+		// single add
+		r++;
+		addData(r, newmap);
+		return 1;
+	}
+	// double add:
+	SingleMapping *newmap = new SingleMapping(begin, m->to);
+	newmap->to.add(mr);
+	SingleMapping *newmap2 = new SingleMapping(end + 1, m->to);
+	addData(r + 1, newmap);
+	addData(r + 2, newmap2);
+	r += 2;
+	return 2;
+}
+
+void MultiMap::add(int begin, int end, const MultiRange& to)
+{
+	if (to.isEmpty()) return;
+	if (end < begin) return;
+	int r1 = findData(begin);
+	int r2 = findData(end);
+	if (r1 == r2)
+	{
+		addRangeBeginEnd(r1, begin, end, to);
+	}
 	else
+	{
+		r2 += addRangeBeginEnd(r1, begin, getBegin(r1 + 1) - 1, to);
+		r1++;
+		for (; r1 < r2; r1++)
+			r2 += addRange(r1, to);
+		addRangeBeginEnd(r1, getBegin(r1), end, to);
+	}
+}
+
+const MultiRange& MultiMap::map(int x) const
+{
+	static MultiRange empty;
+	int m = findData(x);
+	if (m < 0) return empty;
+	SingleMapping *sm = getMapping(m);
+	return sm->to;
+}
+
+MultiRange MultiMap::map(int begin, int end) const
+{
+	MultiRange mr;
+	int m = findData(begin);
+	for (; m < rangeCount(); m++)
+		if (m >= 0)
 		{
-		b=c-1;
-		}
-	}
-}
-
-int MultiMap::addRange(int &r,const MultiRange& mr)
-{
-// precondition: 0 <= r < (mappingCount()-1)
-// 1.maybe change mapping in this range
-int ret=0;
-SingleMapping *sm=getMapping(r);
-if (sm->to.contains(mr)) return 0; // do nothing
-sm->to.add(mr);
-// after adding mr to this mapping it could be the same as the previous/next one
-if (r>0) // prev exists
-	{
-	SingleMapping *prev=getMapping(r-1);
-	if (prev->to == sm->to)
-		{ // splice with prev
-		removeData(r);
-		delete sm;
-		sm=prev;
-		r--;
-		ret--;
-		}
-	}
-if (r<(mappingCount()-2)) // next exists
-	{
-	SingleMapping *next=getMapping(r+1);
-	if (next->to == sm->to)
-		{ // splice with next
-		removeData(r+1);
-		delete next;
-		ret--;
-		r--;
-		}
-	}
-return ret;
-}
-
-int MultiMap::addRangeBeginEnd(int &r,int begin,int end,const MultiRange& mr)
-{
-// precondition: -1 <= r < mappingCount()
-//               begin <= end
-//               begin >= mapping.begin
-//               end < nextmapping.begin
-SingleMapping *m,*m2,*m1;
-if (r<0)
-	{
-	if (mappingCount())
-		{
-		m=getMapping(0);
-		if (end==(m->begin-1))
-			{ // adjacent to m
-			if (m->to==mr)
-				{ // shift only
-				m->begin=begin;
-				return 0;
-				}
-			// single add
-			SingleMapping *newmap=new SingleMapping(begin,mr);
-			addData(0,newmap);
-			r=0;
-			return 1;
-			}
-		}
-	// double add
-	SingleMapping *newmap=new SingleMapping(begin,mr);
-	SingleMapping *newmap2=new SingleMapping(end+1);
-	addData(0,newmap);
-	addData(1,newmap2);
-	r=1;
-	return 2;
-	}
-
-if (r==(mappingCount()-1))
-	{
-	m=getMapping(r);
-	m1=getMapping(r-1);
-	if (begin==m->begin)
-		{ // adjacent
-		if (m1->to==mr)
-			{ // shift only
-			m->begin=end+1;
-			return 0;
-			}
-		// single add
-		m->begin=end+1;
-		SingleMapping *newmap=new SingleMapping(begin,mr);
-		addData(r,newmap);
-		return 1;
-		}
-	// double add
-	SingleMapping *newmap=new SingleMapping(begin,mr);
-	SingleMapping *newmap2=new SingleMapping(end+1);
-	addData(r+1,newmap);
-	addData(r+2,newmap2);
-	r+=2;
-	return 2;
-	}
-
-m=getMapping(r);
-if (m->to.contains(mr)) return 0;
-if (begin==m->begin) // begin at range boundary
-	{
-	m2=getMapping(r+1);
-	if (end==(m2->begin-1)) return addRange(r,mr);
-
-	SingleMapping *newmap=new SingleMapping(begin,m->to);
-	newmap->to.add(mr);
-	if (r>0)
-		{ // join prev possible...
-		m1=getMapping(r-1);
-		if (m1->to==newmap->to)
-			{ // joint prev = shift
-			delete newmap;
-			m->begin=end+1;
-			return 0;
-			}
-		}
-	// single add:
-	m->begin=end+1;
-	addData(r,newmap);
-	return 1;
-	}
-
-m2=getMapping(r+1);
-if (end==(m2->begin-1)) // end at range boundary
-	{
-	SingleMapping *newmap=new SingleMapping(begin,m->to);
-	newmap->to.add(mr);
-	if (r<(mappingCount()-2))
-		{ // join next possible...
-		if (m2->to==newmap->to)
-			{ // joint next = shift
-			m2->begin=begin;
-			delete newmap;
-			return 0;
-			}
-		}
-	// single add
-	r++;
-	addData(r,newmap);
-	return 1;
-	}
-// double add:
-SingleMapping *newmap=new SingleMapping(begin,m->to);
-newmap->to.add(mr);
-SingleMapping *newmap2=new SingleMapping(end+1,m->to);
-addData(r+1,newmap);
-addData(r+2,newmap2);
-r+=2;
-return 2;
-}
-
-void MultiMap::add(int begin,int end,const MultiRange& to)
-{
-if (to.isEmpty()) return;
-if (end<begin) return;
-int r1=findData(begin);
-int r2=findData(end);
-if (r1==r2)
-	{
-	addRangeBeginEnd(r1,begin,end,to);
-	}
-else
-	{
-	r2+=addRangeBeginEnd(r1,begin,getBegin(r1+1)-1,to);
-	r1++;
-	for (;r1<r2;r1++)
-		r2+=addRange(r1,to);
-	addRangeBeginEnd(r1,getBegin(r1),end,to);
-	}
-}
-
-const MultiRange& MultiMap::map(int x) const
-{
-static MultiRange empty;
-int m=findData(x);
-if (m<0) return empty;
-SingleMapping *sm=getMapping(m);
-return sm->to;
-}
-
-MultiRange MultiMap::map(int begin,int end) const
-{
-MultiRange mr;
-int m=findData(begin);
-for (;m<rangeCount();m++)
-	if (m>=0)
-	{
-	SingleMapping *sm=getMapping(m);
-	if (sm->begin > end) break;
-	mr.add(sm->to);
-	}
-return mr;
+		SingleMapping *sm = getMapping(m);
+		if (sm->begin > end) break;
+		mr.add(sm->to);
+		}
+	return mr;
 }
 
 MultiRange MultiMap::map(const MultiRange& ranges) const
 {
-MultiRange mr;
-for(int i=0;i<ranges.rangeCount();i++)
-	mr.add(map(ranges.getRange(i)));
-return mr;
+	MultiRange mr;
+	for (int i = 0; i < ranges.rangeCount(); i++)
+		mr.add(map(ranges.getRange(i)));
+	return mr;
 }
 
 IRange MultiMap::getRange(int i) const
 {
-if ((i<0)||(i>(data.size()-1))) return IRange();
-return IRange(getBegin(i),getBegin(i+1)-1);
+	if ((i<0) || (i>(data.size() - 1))) return IRange();
+	return IRange(getBegin(i), getBegin(i + 1) - 1);
 }
 
 void MultiMap::operator=(const MultiMap& mm)
 {
-clear();
-for(int i=0;i<mm.mappingCount();i++)
-	addData(i,new SingleMapping(*mm.getMapping(i)));
-}
-
-void MultiMap::addCombined(const MultiMap& m1,const MultiMap& m2)
-{
-for(int i=0;i<m1.rangeCount();i++)
-	{
-	IRange r=m1.getRange(i);
-	add(r,m2.map(m1.getMapping(i)->to));
-	}
-}
-
-void MultiMap::add(const MultiRange& from,const MultiRange& to)
-{
-for(int i=0;i<from.rangeCount();i++)
-	add(from.getRange(i),to);
+	clear();
+	for (int i = 0; i < mm.mappingCount(); i++)
+		addData(i, new SingleMapping(*mm.getMapping(i)));
+}
+
+void MultiMap::addCombined(const MultiMap& m1, const MultiMap& m2)
+{
+	for (int i = 0; i < m1.rangeCount(); i++)
+	{
+		IRange r = m1.getRange(i);
+		add(r, m2.map(m1.getMapping(i)->to));
+	}
+}
+
+void MultiMap::add(const MultiRange& from, const MultiRange& to)
+{
+	for (int i = 0; i < from.rangeCount(); i++)
+		add(from.getRange(i), to);
 }
 
 void MultiMap::addReversed(const MultiMap& m)
 {
-for(int i=0;i<m.rangeCount();i++)
-	{
-	IRange r=m.getRange(i);
-	const MultiRange& mr=m.getMapping(i)->to;
-	for (int j=0;j<mr.rangeCount();j++)
-		add(mr.getRange(j),r);
+	for (int i = 0; i < m.rangeCount(); i++)
+	{
+		IRange r = m.getRange(i);
+		const MultiRange& mr = m.getMapping(i)->to;
+		for (int j = 0; j < mr.rangeCount(); j++)
+			add(mr.getRange(j), r);
 	}
 }
 
 MultiMap::~MultiMap()
-{ clear();}
+{
+	clear();
+}
 
 void MultiMap::clear()
 {
-for(int i=0;i<data.size();i++)
-	delete getData(i);
-data.clear();
+	for (int i = 0; i < data.size(); i++)
+		delete getData(i);
+	data.clear();
 }
 
@@ -293,38 +295,38 @@
 void MultiMap::print() const
 {
-printf("{ ");
-for (int i=0;i<(mappingCount()-1);i++)
-	{
-	if (i) printf("  ");
-	SingleMapping *sm=getMapping(i);
-	SingleMapping *sm2=getMapping(i+1);
-	if (sm2->begin==sm->begin+1)
-		printf("[%d] -> ",sm->begin);
-	else
-		printf("[%d-%d] -> ",sm->begin,sm2->begin-1);
-	sm->to.print();
-	printf("\n");
-	}
-printf("}\n");
+	printf("{ ");
+	for (int i = 0; i < (mappingCount() - 1); i++)
+	{
+		if (i) printf("  ");
+		SingleMapping *sm = getMapping(i);
+		SingleMapping *sm2 = getMapping(i + 1);
+		if (sm2->begin == sm->begin + 1)
+			printf("[%d] -> ", sm->begin);
+		else
+			printf("[%d-%d] -> ", sm->begin, sm2->begin - 1);
+		sm->to.print();
+		printf("\n");
+	}
+	printf("}\n");
 }
 
 void MultiMap::print2() const
 {
-int y;
-int id=0,id2;
-if (isEmpty())
-	{
-	printf("{ empty }\n");
-	return;
-	}
-printf("{\n");
-for (y=getBegin();y<=getEnd();y++)
-	{
-	id2=findMappingId(y+1);
-	printf("%2d %c",y,(id2!=id)?'_':' ');
-	id=id2;
-	map(y).print2();
-	printf("\n");
-	}
-printf("}\n");
-}
+	int y;
+	int id = 0, id2;
+	if (isEmpty())
+	{
+		printf("{ empty }\n");
+		return;
+	}
+	printf("{\n");
+	for (y = getBegin(); y <= getEnd(); y++)
+	{
+		id2 = findMappingId(y + 1);
+		printf("%2d %c", y, (id2 != id) ? '_' : ' ');
+		id = id2;
+		map(y).print2();
+		printf("\n");
+	}
+	printf("}\n");
+}
Index: cpp/frams/util/multimap.h
===================================================================
--- cpp/frams/util/multimap.h	(revision 732)
+++ cpp/frams/util/multimap.h	(revision 733)
@@ -10,65 +10,65 @@
 class SingleMapping
 {
-  public:
-SingleMapping(int b,const MultiRange& t):begin(b),to(t) {}
-SingleMapping(int b):begin(b) {}
-SingleMapping(const SingleMapping& sm):begin(sm.begin),to(sm.to) {}
-int begin;
-MultiRange to;
+public:
+	SingleMapping(int b, const MultiRange& t) :begin(b), to(t) {}
+	SingleMapping(int b) :begin(b) {}
+	SingleMapping(const SingleMapping& sm) :begin(sm.begin), to(sm.to) {}
+	int begin;
+	MultiRange to;
 };
 
 /** MultiMap - used for conversion mapping.
-    Read about how mappings work: http://www.framsticks.com/files/common/GeneticMappingsInArtificialGenomes.pdf
-    see @ref convmap
-*/
+	Read about how mappings work: http://www.framsticks.com/files/common/GeneticMappingsInArtificialGenomes.pdf
+	see @ref convmap
+	*/
 class MultiMap
 {
-/** list of (SingleMapping*) */
-SList data;
+	/** list of (SingleMapping*) */
+	SList data;
 
-SingleMapping* getData(int i) const {return (SingleMapping*)data(i);}
-void addData(int i,SingleMapping* mapping) {data.insert(i,(void*)mapping);}
-void removeData(int i) {data.remove(i);}
-int findData(int x) const;
-int getBegin(int i) const {return getData(i)->begin;}
+	SingleMapping* getData(int i) const { return (SingleMapping*)data(i); }
+	void addData(int i, SingleMapping* mapping) { data.insert(i, (void*)mapping); }
+	void removeData(int i) { data.remove(i); }
+	int findData(int x) const;
+	int getBegin(int i) const { return getData(i)->begin; }
 
-// addRangeXXX return the shift for range numbers > r
-int addRange(int &r,const MultiRange& mr);
-// value of 'r' is adjusted according to its range number change
-int addRangeBeginEnd(int &r,int begin,int end,const MultiRange& mr);
+	// addRangeXXX return the shift for range numbers > r
+	int addRange(int &r, const MultiRange& mr);
+	// value of 'r' is adjusted according to its range number change
+	int addRangeBeginEnd(int &r, int begin, int end, const MultiRange& mr);
 
-  public:
-MultiMap() {}
-MultiMap(const MultiMap& mm) {operator=(mm);}
-~MultiMap();
-void operator=(const MultiMap& mm);
+public:
+	MultiMap() {}
+	MultiMap(const MultiMap& mm) { operator=(mm); }
+	~MultiMap();
+	void operator=(const MultiMap& mm);
 
-void clear();
-int isEmpty() const {return data.size()==0;}
-int mappingCount() const {return data.size();}
-SingleMapping* getMapping(int i) const {return (SingleMapping*)getData(i);}
-int findMappingId(int x) const {return findData(x);}
-int rangeCount() const {return isEmpty()?0:data.size()-1;}
-IRange getRange(int i) const;
+	void clear();
+	int isEmpty() const { return data.size() == 0; }
+	int mappingCount() const { return data.size(); }
+	SingleMapping* getMapping(int i) const { return (SingleMapping*)getData(i); }
+	int findMappingId(int x) const { return findData(x); }
+	int rangeCount() const { return isEmpty() ? 0 : data.size() - 1; }
+	IRange getRange(int i) const;
 
-int getBegin() const;
-int getEnd() const;
+	int getBegin() const;
+	int getEnd() const;
 
-void add(const IRange& from,const IRange& to) {add(from.begin, from.end, MultiRange(to));}
-void add(const IRange& from,const MultiRange& to) {add(from.begin, from.end, to);}
-void add(int from1,int from2,int to1,int to2) {add(from1,from2,MultiRange(to1,to2));}
-void add(int from1,int from2,const MultiRange& to);
-void add(const MultiRange& from,const MultiRange& to);
-void add(const MultiMap& mm);
-void addCombined(const MultiMap& m1,const MultiMap& m2);
-void addReversed(const MultiMap& mm);
+	void add(const IRange& from, const IRange& to) { add(from.begin, from.end, MultiRange(to)); }
+	void add(const IRange& from, const MultiRange& to) { add(from.begin, from.end, to); }
+	void add(int from1, int from2, int to1, int to2) { add(from1, from2, MultiRange(to1, to2)); }
+	void add(int from1, int from2, const MultiRange& to);
+	void add(const MultiRange& from, const MultiRange& to);
+	void add(const MultiMap& mm);
+	void addCombined(const MultiMap& m1, const MultiMap& m2);
+	void addReversed(const MultiMap& mm);
 
-const MultiRange& map(int x) const;
-MultiRange map(int begin,int end) const;
-MultiRange map(const IRange& range) const {return map(range.begin, range.end);}
-MultiRange map(const MultiRange& ranges) const;
+	const MultiRange& map(int x) const;
+	MultiRange map(int begin, int end) const;
+	MultiRange map(const IRange& range) const { return map(range.begin, range.end); }
+	MultiRange map(const MultiRange& ranges) const;
 
-void print() const;
-void print2() const;
+	void print() const;
+	void print2() const;
 };
 
Index: cpp/frams/util/multirange.cpp
===================================================================
--- cpp/frams/util/multirange.cpp	(revision 732)
+++ cpp/frams/util/multirange.cpp	(revision 733)
@@ -10,23 +10,23 @@
 int IRange::operator==(const IRange& r)
 {
-if (isEmpty()&&r.isEmpty()) return 1;
-return (begin==r.begin)&&(end==r.end);
+	if (isEmpty() && r.isEmpty()) return 1;
+	return (begin == r.begin) && (end == r.end);
 }
 
 void IRange::intersect(const IRange& r)
 {
-if (r.begin>begin) begin=r.begin;
-if (r.end<end) end=r.end;
+	if (r.begin > begin) begin = r.begin;
+	if (r.end < end) end = r.end;
 }
 void IRange::add(const IRange& r)
 {
-if (r.begin<begin) begin=r.begin;
-if (r.end>end) end=r.end;
+	if (r.begin < begin) begin = r.begin;
+	if (r.end > end) end = r.end;
 }
 
 void IRange::print() const
 {
-if (begin==end) printf("[%d]",begin);
-else printf("[%d-%d]",begin,end);
+	if (begin == end) printf("[%d]", begin);
+	else printf("[%d-%d]", begin, end);
 }
 
@@ -35,159 +35,161 @@
 void MultiRange::print() const
 {
-printf("[");
-for (int i=0;i<data.size();i+=2)
-	{
-	int b=getData(i);
-	int e=getData(i+1);
-	if (i) printf(",");
-	if (b==e) printf("%d",b);
-	else printf("%d-%d",b,e);
-	}
-printf("]");
+	printf("[");
+	for (int i = 0; i < data.size(); i += 2)
+	{
+		int b = getData(i);
+		int e = getData(i + 1);
+		if (i) printf(",");
+		if (b == e) printf("%d", b);
+		else printf("%d-%d", b, e);
+	}
+	printf("]");
 }
 
 void MultiRange::print2() const
 {
-const IRange& r=singleRange();
-for(int i=0;i<=r.end;i++)
-	printf(contains(i)?"X":".");
+	const IRange& r = singleRange();
+	for (int i = 0; i <= r.end; i++)
+		printf(contains(i) ? "X" : ".");
 }
 
 void MultiRange::shift(int delta)
 {
-for(int i=0;i<data.size();i++)
-	data.get(i)+=delta;
+	for (int i = 0; i<data.size(); i++)
+		data.get(i) += delta;
 }
 
 int MultiRange::findRange(int x) const
 {
-if (isEmpty()) return -1;
-if (getData(0)>x) return -1;
-int a,b,c;
-int n=rangeCount()-1;
-a=0; b=n; // find c = last range with begin<=x
-while(1){
-	c=(a+b+1)/2;
-	if (getBegin(c)<=x)
-		{
-		if ((c==n)||(getBegin(c+1)>x)) return c;
-		a=c;
-		}
-	else
-		{
-		b=c-1;
-		}
-	}
-}
-
-void MultiRange::addRange(int i,int b,int e)
-{
-data.insert(2*i,b);
-data.insert(2*i+1,e);
-}
-
-void MultiRange::removeRanges(int r1,int r2)
-{
-//data.remove(2*r1,(r2-r1)*2+2);
-for (;r2>=r1;r2--)
-	removeRange(r2);
+	if (isEmpty()) return -1;
+	if (getData(0)>x) return -1;
+	int a, b, c;
+	int n = rangeCount() - 1;
+	a = 0; b = n; // find c = last range with begin<=x
+	while (1){
+		c = (a + b + 1) / 2;
+		if (getBegin(c) <= x)
+		{
+			if ((c == n) || (getBegin(c + 1) > x)) return c;
+			a = c;
+		}
+		else
+		{
+			b = c - 1;
+		}
+	}
+}
+
+void MultiRange::addRange(int i, int b, int e)
+{
+	data.insert(2 * i, b);
+	data.insert(2 * i + 1, e);
+}
+
+void MultiRange::removeRanges(int r1, int r2)
+{
+	//data.remove(2*r1,(r2-r1)*2+2);
+	for (; r2 >= r1; r2--)
+		removeRange(r2);
 }
 
 void MultiRange::removeRange(int i)
 {
-data.remove(2*i,2);
+	data.remove(2 * i, 2);
 }
 
 void MultiRange::clear()
-{data.clear();}
+{
+	data.clear();
+}
 
 int MultiRange::isEmpty() const
 {
-return rangeCount()==0;
+	return rangeCount() == 0;
 }
 
 IRange MultiRange::singleRange() const
 {
-if (isEmpty()) return IRange();
-int b=getData(0);
-int e=getData(data.size()-1);
-return IRange(b,e);
+	if (isEmpty()) return IRange();
+	int b = getData(0);
+	int e = getData(data.size() - 1);
+	return IRange(b, e);
 }
 
 int MultiRange::rangeCount() const
 {
-return data.size()/2;
+	return data.size() / 2;
 }
 
 IRange MultiRange::getRange(int i) const
 {
-if ((i<0)||(i>=rangeCount())) return IRange();
-return IRange(getData(2*i),getData(2*i+1));
+	if ((i < 0) || (i >= rangeCount())) return IRange();
+	return IRange(getData(2 * i), getData(2 * i + 1));
 }
 
 void MultiRange::remove(int begin, int end)
 {
-if (end<begin) return; // NOP
-int count=rangeCount();
-if (!count) return;
-int r1=findRange(begin);
-int r2=findRange(end);
-if (r2<0) return; // NOP
-if (r1==r2)
-	{
-	int e=getEnd(r1);
-	int b=getBegin(r1);
-	if (begin<=e)
-		{
-		if (end>=e)
+	if (end < begin) return; // NOP
+	int count = rangeCount();
+	if (!count) return;
+	int r1 = findRange(begin);
+	int r2 = findRange(end);
+	if (r2<0) return; // NOP
+	if (r1 == r2)
+	{
+		int e = getEnd(r1);
+		int b = getBegin(r1);
+		if (begin <= e)
+		{
+			if (end >= e)
 			{
-			if (begin>b)
-				setEnd(r1,begin-1);
+				if (begin>b)
+					setEnd(r1, begin - 1);
+				else
+					removeRange(r1);
+			}
 			else
-				removeRange(r1);
-			}
-		else
 			{
-			if (begin>b)
+				if (begin > b)
 				{ //split
-				addRange(r1+1,end+1,e);
-				setEnd(r1,begin-1);
+					addRange(r1 + 1, end + 1, e);
+					setEnd(r1, begin - 1);
 				}
-			else
+				else
 				{
-				setBegin(r1,end+1);
+					setBegin(r1, end + 1);
 				}
 			}
 		}
 	}
-else
-	{
-	if (r1>=0)
-		{
-		int e1=getEnd(r1);
-		int b1=getBegin(r1);
-		if (begin<=e1)
+	else
+	{
+		if (r1 >= 0)
+		{
+			int e1 = getEnd(r1);
+			int b1 = getBegin(r1);
+			if (begin <= e1)
 			{
-			if (begin==b1)
+				if (begin == b1)
 				{
-				removeRange(r1);
-				r2--;
-				r1--;
+					removeRange(r1);
+					r2--;
+					r1--;
 				}
-			else
+				else
 				{
-				setEnd(r1,begin-1);
+					setEnd(r1, begin - 1);
 				}
 			}
 		}
-	int e2=getEnd(r2);
-	if (end<e2)
-		{
-		setBegin(r2,end+1);
-		removeRanges(r1+1,r2-1);
-		}
-	else
-		{
-		removeRanges(r1+1,r2);
+		int e2 = getEnd(r2);
+		if (end < e2)
+		{
+			setBegin(r2, end + 1);
+			removeRanges(r1 + 1, r2 - 1);
+		}
+		else
+		{
+			removeRanges(r1 + 1, r2);
 		}
 	}
@@ -196,61 +198,61 @@
 void MultiRange::add(int begin, int end)
 {
-if (end<begin) return; // NOP
-int count=rangeCount();
-int last=count-1;
-int r1=findRange(begin);
-int r2=findRange(end);
-if (r2<0) // special case: before first range
-	{
-	if (count&&(getData(0)==(end+1)))
-		setData(0,begin);
-	else
-		addRange(0,begin,end);
-	return;
-	}
-if (r1<0) // special case: begin is before first range
-	{
-	setData(0,begin);
-	r1=0;
-	}
-// now r1>=0 and r2>=0
-int joinbegin=(begin<=(getEnd(r1)+1));
-int joinend=(r2<last)&&(end>=(getBegin(r2+1)-1));
-const int SAME=1;
-const int JOINBEGIN=2;
-const int JOINEND=4;
-int action=((r1==r2)?SAME:0)+(joinbegin?JOINBEGIN:0)+(joinend?JOINEND:0);
-switch(action)
-	{
-	case SAME+JOINBEGIN+JOINEND: // remove 1 range
-		setEnd(r1,getEnd(r1+1));
-		removeRange(r1+1);
-		break;
-	case SAME+JOINBEGIN: // extend 1 range
-		setEnd(r1,max(getEnd(r2),end));
-		break;
-	case SAME+JOINEND: // extend 1 range
-		setBegin(r1+1,begin);
+	if (end < begin) return; // NOP
+	int count = rangeCount();
+	int last = count - 1;
+	int r1 = findRange(begin);
+	int r2 = findRange(end);
+	if (r2 < 0) // special case: before first range
+	{
+		if (count && (getData(0) == (end + 1)))
+			setData(0, begin);
+		else
+			addRange(0, begin, end);
+		return;
+	}
+	if (r1 < 0) // special case: begin is before first range
+	{
+		setData(0, begin);
+		r1 = 0;
+	}
+	// now r1>=0 and r2>=0
+	int joinbegin = (begin <= (getEnd(r1) + 1));
+	int joinend = (r2 < last) && (end >= (getBegin(r2 + 1) - 1));
+	const int SAME = 1;
+	const int JOINBEGIN = 2;
+	const int JOINEND = 4;
+	int action = ((r1 == r2) ? SAME : 0) + (joinbegin ? JOINBEGIN : 0) + (joinend ? JOINEND : 0);
+	switch (action)
+	{
+	case SAME + JOINBEGIN + JOINEND: // remove 1 range
+		setEnd(r1, getEnd(r1 + 1));
+		removeRange(r1 + 1);
+		break;
+	case SAME + JOINBEGIN: // extend 1 range
+		setEnd(r1, max(getEnd(r2), end));
+		break;
+	case SAME + JOINEND: // extend 1 range
+		setBegin(r1 + 1, begin);
 		break;
 	case SAME: // add 1 range
-		addRange(r1+1,begin,end);
-		break;
-
-	case JOINBEGIN+JOINEND: // extend r2+1
-		setBegin(r2+1,getBegin(r1));
-		removeRanges(r1,r2);
+		addRange(r1 + 1, begin, end);
+		break;
+
+	case JOINBEGIN + JOINEND: // extend r2+1
+		setBegin(r2 + 1, getBegin(r1));
+		removeRanges(r1, r2);
 		break;
 	case JOINBEGIN: // extend r1
-		setEnd(r1,max(end,getEnd(r2)));
-		removeRanges(r1+1,r2);
+		setEnd(r1, max(end, getEnd(r2)));
+		removeRanges(r1 + 1, r2);
 		break;
 	case JOINEND: // extend r2+1
-		setBegin(r2+1,begin);
-		removeRanges(r1+1,r2);
+		setBegin(r2 + 1, begin);
+		removeRanges(r1 + 1, r2);
 		break;
 	case 0: // extend r2
-		setBegin(r2,begin);
-		setEnd(r2,max(end,getEnd(r2)));
-		removeRanges(r1+1,r2-1);
+		setBegin(r2, begin);
+		setEnd(r2, max(end, getEnd(r2)));
+		removeRanges(r1 + 1, r2 - 1);
 		break;
 	}
@@ -259,8 +261,8 @@
 void MultiRange::remove(const MultiRange &mr)
 {
-for(int i=0;i<mr.rangeCount();i++)
-	{
-	IRange r=mr.getRange(i);
-	remove(r);
+	for (int i = 0; i < mr.rangeCount(); i++)
+	{
+		IRange r = mr.getRange(i);
+		remove(r);
 	}
 }
@@ -268,8 +270,8 @@
 void MultiRange::add(const MultiRange &mr)
 {
-for(int i=0;i<mr.rangeCount();i++)
-	{
-	IRange r=mr.getRange(i);
-	add(r);
+	for (int i = 0; i < mr.rangeCount(); i++)
+	{
+		IRange r = mr.getRange(i);
+		add(r);
 	}
 }
@@ -277,41 +279,41 @@
 void MultiRange::intersect(const MultiRange &mr)
 {
-// = this - (1-mr)
-MultiRange full(singleRange());
-full.remove(mr);
-remove(full);
+	// = this - (1-mr)
+	MultiRange full(singleRange());
+	full.remove(mr);
+	remove(full);
 }
 
 int MultiRange::contains(const MultiRange &mr) const
 {
-for(int i=0;i<mr.rangeCount();i++)
-	{
-	IRange r=mr.getRange(i);
-	if (!contains(r)) return 0;
-	}
-return 1;
+	for (int i = 0; i < mr.rangeCount(); i++)
+	{
+		IRange r = mr.getRange(i);
+		if (!contains(r)) return 0;
+	}
+	return 1;
 }
 
 int MultiRange::contains(int x) const
 {
-int r=findRange(x);
-if (r<0) return 0;
-return getEnd(r)>=x;
+	int r = findRange(x);
+	if (r < 0) return 0;
+	return getEnd(r) >= x;
 }
 
 int MultiRange::contains(const IRange& r) const
 {
-if (r.isEmpty()) return 0;
-int r1=findRange(r.begin);
-if (r1<0) return 0;
-return getRange(r1).contains(r);
+	if (r.isEmpty()) return 0;
+	int r1 = findRange(r.begin);
+	if (r1 < 0) return 0;
+	return getRange(r1).contains(r);
 }
 
 void MultiRange::intersect(int begin, int end)
 {
-if (isEmpty()) return;
-if (end<begin) {clear(); return;}
-IRange sr=singleRange();
-remove(sr.begin, begin-1);
-remove(end+1, sr.end);
-}
+	if (isEmpty()) return;
+	if (end < begin) { clear(); return; }
+	IRange sr = singleRange();
+	remove(sr.begin, begin - 1);
+	remove(end + 1, sr.end);
+}
Index: cpp/frams/util/multirange.h
===================================================================
--- cpp/frams/util/multirange.h	(revision 732)
+++ cpp/frams/util/multirange.h	(revision 733)
@@ -12,24 +12,24 @@
    - (a,a) contains single integer: a
    - (a,b) contains [b-a+1] integers
- */
+   */
 class IRange
 {
-  public:
-int begin,end;
-IRange():begin(0),end(0) {}
-IRange(int b,int e):begin(b),end(e) {}
-IRange(const IRange& r):begin(r.begin),end(r.end) {}
-int size() const {return end-begin+1;}
-int isEmpty() const {return end<begin;}
-void makeEmpty() {end=begin;}
-void set(int b,int e) {begin=b; end=e;}
-void intersect(const IRange& r);
-void add(const IRange& r);
-/** all empty ranges are equal */
-int operator==(const IRange& r);
-void operator=(const IRange& r) {begin=r.begin; end=r.end;}
-int contains(int x) {return (x>=begin)&&(x<=end);}
-int contains(const IRange& r) {return !r.isEmpty()&&contains(r.begin)&&contains(r.end);}
-void print() const;
+public:
+	int begin, end;
+	IRange() :begin(0), end(0) {}
+	IRange(int b, int e) :begin(b), end(e) {}
+	IRange(const IRange& r) :begin(r.begin), end(r.end) {}
+	int size() const { return end - begin + 1; }
+	int isEmpty() const { return end < begin; }
+	void makeEmpty() { end = begin; }
+	void set(int b, int e) { begin = b; end = e; }
+	void intersect(const IRange& r);
+	void add(const IRange& r);
+	/** all empty ranges are equal */
+	int operator==(const IRange& r);
+	void operator=(const IRange& r) { begin = r.begin; end = r.end; }
+	int contains(int x) { return (x >= begin) && (x <= end); }
+	int contains(const IRange& r) { return !r.isEmpty() && contains(r.begin) && contains(r.end); }
+	void print() const;
 };
 
@@ -37,68 +37,63 @@
 class MultiRange
 {
-/** subsequent ranges in array, stored as: {begin1,end1,begin2,end2,...}
-    there are data.size()/2 ranges.
-    all ranges are sorted by 'begin' value.
-    ranges cannot intersect.
- */
-SListTempl<int> data;
-int getData(int i) const {return (int)data(i);}
-void setData(int i,int x) {data.set(i,x);}
-int getBegin(int i) const {return getData(2*i);}
-int getEnd(int i) const {return getData(2*i+1);}
-void setBegin(int i,int x) {setData(2*i,x);}
-void setEnd(int i,int x) {setData(2*i+1,x);}
-/** find the last range with begin<=x
- @return -1 if not found */
-int findRange(int x) const;
-void addRange(int i,int b,int e);
-void removeRange(int i);
-void removeRanges(int r1,int r2);
+	/** subsequent ranges in array, stored as: {begin1,end1,begin2,end2,...}
+		there are data.size()/2 ranges.
+		all ranges are sorted by 'begin' value.
+		ranges cannot intersect.
+		*/
+	SListTempl<int> data;
+	int getData(int i) const { return (int)data(i); }
+	void setData(int i, int x) { data.set(i, x); }
+	int getBegin(int i) const { return getData(2 * i); }
+	int getEnd(int i) const { return getData(2 * i + 1); }
+	void setBegin(int i, int x) { setData(2 * i, x); }
+	void setEnd(int i, int x) { setData(2 * i + 1, x); }
+	/** find the last range with begin<=x
+	 @return -1 if not found */
+	int findRange(int x) const;
+	void addRange(int i, int b, int e);
+	void removeRange(int i);
+	void removeRanges(int r1, int r2);
 
-  public:
-MultiRange() {}
-MultiRange(const MultiRange &mr) {data=mr.data;}
-void operator=(const MultiRange &mr) {data=mr.data;}
-MultiRange(const IRange &r) {add(r);}
-MultiRange(int begin,int end) {add(begin,end);}
-MultiRange(int x) {add(x);}
+public:
+	MultiRange() {}
+	MultiRange(const MultiRange &mr) { data = mr.data; }
+	void operator=(const MultiRange &mr) { data = mr.data; }
+	MultiRange(const IRange &r) { add(r); }
+	MultiRange(int begin, int end) { add(begin, end); }
+	MultiRange(int x) { add(x); }
 
-int operator==(const MultiRange &mr) const {return data==mr.data;}
+	int operator==(const MultiRange &mr) const { return data == mr.data; }
 
-void clear();
-int isEmpty() const;
+	void clear();
+	int isEmpty() const;
 
-IRange singleRange() const;
-int rangeCount() const;
-IRange getRange(int i) const;
+	IRange singleRange() const;
+	int rangeCount() const;
+	IRange getRange(int i) const;
 
-void add(int x) {add(x,x);}
-void add(const IRange& r) {add(r.begin,r.end);}
-void add(int begin, int end);
-void add(const MultiRange &mr);
+	void add(int x) { add(x, x); }
+	void add(const IRange& r) { add(r.begin, r.end); }
+	void add(int begin, int end);
+	void add(const MultiRange &mr);
 
-void remove(int x) {remove(x,x);}
-void remove(const IRange& r) {remove(r.begin,r.end);}
-void remove(int begin, int end);
-void remove(const MultiRange &mr);
+	void remove(int x) { remove(x, x); }
+	void remove(const IRange& r) { remove(r.begin, r.end); }
+	void remove(int begin, int end);
+	void remove(const MultiRange &mr);
 
-int contains(int x) const;
-int contains(const IRange& r) const;
-int contains(const MultiRange &mr) const;
+	int contains(int x) const;
+	int contains(const IRange& r) const;
+	int contains(const MultiRange &mr) const;
 
-void intersect(const IRange& r) {intersect(r.begin,r.end);}
-void intersect(int begin, int end);
-void intersect(const MultiRange &mr);
+	void intersect(const IRange& r) { intersect(r.begin, r.end); }
+	void intersect(int begin, int end);
+	void intersect(const MultiRange &mr);
 
-void shift(int delta);
+	void shift(int delta);
 
-void print() const;
-void print2() const;
+	void print() const;
+	void print2() const;
 };
 
 #endif
-
-
-
-
-
