////////////////////////////////////////////////////////////////////////////////// // This file is part of Toolkit for Conceptual Modeling (TCM). // (c) copyright 2001, Universiteit Twente. // Author: Rik Eshuis (eshuis@cs.utwente.nl). // // TCM is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // TCM is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with TCM; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //////////////////////////////////////////////////////////////////////////////// #ifndef __BAG_C #define __BAG_C #include "bag.h" //template class Bag; //template class List; template Bag::Bag(){ } template Bag::Bag(const List &l, int n){ int i=l.count(); int j; for (j=0;j Bag::Bag(const Bag &b){ list=b.list; int i=list.count(); int j; for (j=0;j void Bag::add(const T &e){ add(e,1); } template void Bag::add(const T &e,int n){ int i=0; i = list.find(e); if (i>=0) countl[i]=countl[i]+n; else //i==-1 { list.add(e); countl[list.count()-1]=n; } } template bool Bag::remove(const T &e){ if (count(e)>0){ add(e,-1); return True; } else return False; } /// return list is set template bool Bag::isSet() const{ int i=list.count(); int j; for (j=0;j1) return False; } return True; } /// count the number of times e occurs in the list template int Bag::count(const T &e) const{ int i= list.find(e); i = list.find(e); if (i<0) return 0; else return countl[i]; } /// return if bag contains bag b template bool Bag::contains(Bag &b) const{ List lt; b.GetList(lt); int i=lt.count(); int j; for (j=0;j void Bag::join(const Bag &l) { List lt; l.GetList(lt); int i=lt.count(); int j; for (j=0;j bool Bag::diff( Bag &l) { List lt; l.GetList(lt); int i=lt.count(); int j; for (j=0;j int Bag::length(void){ int i=list.count(); int length=0; int j=0; for (j=0;j void Bag::GetSet(List *li){ int i=list.count(); int j; for (j=0;j0) li->add(list[j]); } } template void Bag::empty(){ list.empty(); } #include "../../dg/subject.h" #include "adshyperedge.h" #include "atdactionstatenode.h" template class Bag ; template class Bag ; template class Bag ; #endif