00001
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "indexset.h"
00024
00025
00026 namespace faudes {
00027
00028
00029 IndexSet::IndexSet(void) :
00030 TBaseSet<Idx>()
00031 {
00032 FD_DC("IndexSet(" << this << ")::IndexSet()");
00033 Name("IndexSet");
00034 }
00035
00036
00037 IndexSet::IndexSet(const TBaseSet<Idx>& rOtherSet) :
00038 TBaseSet<Idx>(rOtherSet)
00039 {
00040 FD_DC("IndexSet(" << this << ")::IndexSet(rOtherSet " << &rOtherSet << ")");
00041 }
00042
00043
00044 IndexSet::IndexSet(const std::string& rFilename, const std::string& rLabel) :
00045 TBaseSet<Idx>()
00046 {
00047 FD_DC("IndexSet(" << this << ")::IndexSet(" << rFilename << ")");
00048 Read(rFilename, rLabel);
00049 }
00050
00051
00052 void IndexSet::DoWrite(TokenWriter& rTw, const std::string& rLabel,const Type* pContext) const {
00053 TaIndexSet<AttributeVoid> vcopy= *this;
00054 vcopy.Write(rTw, rLabel, pContext);
00055 }
00056
00057
00058 void IndexSet::DoRead(TokenReader& rTr, const std::string& rLabel,const Type* pContext) {
00059 FD_DC("IndexSet(" << this << ")::DoRead(..): section " << rLabel);
00060 TaIndexSet<AttributeVoid> vcopy;
00061 vcopy.DoRead(rTr,rLabel, pContext);
00062 *this=vcopy;
00063 }
00064
00065
00066 Idx IndexSet::MaxIndex(void) const {
00067 if(Size()==0) return 0;
00068 Iterator it= End();
00069 it--;
00070 return *it;
00071 }
00072
00073
00074 Idx IndexSet::Insert(void) {
00075 FD_DC("IndexSet(" << this << ")::Insert()");
00076 Idx index=MaxIndex()+1;
00077 TBaseSet<Idx>::Insert(index);
00078 return index;
00079 }
00080
00081
00082 bool IndexSet::Insert(Idx idx) {
00083 return TBaseSet<Idx>::Insert(idx);
00084 }
00085
00086
00087
00088 bool IndexSet::Valid(Idx idx) const {
00089 return idx!=0;
00090 }
00091
00092
00093
00094 Idx IndexSet::Signature(void) const {
00095
00096 Idx sig = 0;
00097
00098 Idx i = 1;
00099 Iterator it;
00100
00101 for (it = Begin(); it != End(); ++it) {
00102 sig += *it * i;
00103 ++i;
00104 }
00105 return sig;
00106 }
00107
00108
00109
00110 }