Index: src/Fragmentation/Summation/IndexSet.cpp
===================================================================
--- src/Fragmentation/Summation/IndexSet.cpp	(revision 146c26d1db374118e51291a5034fccfd78aaee7d)
+++ src/Fragmentation/Summation/IndexSet.cpp	(revision 146c26d1db374118e51291a5034fccfd78aaee7d)
@@ -0,0 +1,159 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2011-2012 University of Bonn. All rights reserved.
+ * 
+ *
+ *   This file is part of MoleCuilder.
+ *
+ *    MoleCuilder 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.
+ *
+ *    MoleCuilder 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 MoleCuilder.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * IndexSet.cpp
+ *
+ *  Created on: Apr 24, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "IndexSet.hpp"
+
+#include <boost/foreach.hpp>
+
+/** Constructor for class IndexSet.
+ *
+ */
+IndexSet::IndexSet()
+{}
+
+/** Destructor for class IndexSet.
+ *
+ */
+IndexSet::~IndexSet()
+{
+  clear();
+}
+
+/** Operator for output to std::ostream operator of an IndexSet.
+ * @param ost output stream
+ * @param indexset index set to output
+ * @return ost output stream
+ */
+std::ostream & operator<<(std::ostream &ost, const IndexSet &indexset)
+{
+  ost << "{ ";
+  for (IndexSet::const_iterator iter = indexset.begin();
+      iter != indexset.end();
+      ++iter)
+    ost << *iter << " ";
+  ost << "}";
+  return ost;
+}
+
+/** Checks whether each index of _IndexSet is contained in this subspace:Indices.
+ *
+ * @param _indexset index set to check
+ * @return true - _index is contained, false - at least index is not contained
+ */
+bool IndexSet::contains(const IndexSet &_indexset) const
+{
+  BOOST_FOREACH(size_t index, _indexset) {
+    if (!contains(index)) {  // index not present, then not contained
+      return false;
+    }
+  }
+  return true;
+}
+
+/** Checks whether index is contained in this IndexSet.
+ *
+ * @param _index index to check
+ * @return true - _index is contained, false - at least index is not contained
+ */
+bool IndexSet::contains(const Index_t _index) const
+{
+  const_iterator iter = find(_index);
+  if (iter == end()) {  // index not present, then not contained
+    return false;
+  } else {
+    return true;
+  }
+}
+
+bool IndexSet::operator<(const IndexSet &b) const
+{
+  if (size() < b.size()) {
+    return true;
+  } else if (size() > b.size()) {
+    return false;
+  } else {
+    const_iterator this_iter = begin();
+    const_iterator b_iter = b.begin();
+    for (;(this_iter != end()) && (b_iter != b.end());
+        ++this_iter, ++b_iter) {
+      if (*this_iter < *b_iter) {
+        return true;
+      } else if (*this_iter > *b_iter) {
+        return false;
+      }
+    }
+    return false;
+  }
+}
+
+bool IndexSet::operator>(const IndexSet &b) const
+{
+  if (size() > b.size()) {
+    return true;
+  } else if (size() < b.size()) {
+    return false;
+  } else {
+    const_iterator this_iter = begin();
+    const_iterator b_iter = b.begin();
+    for (;(this_iter != end()) && (b_iter != b.end());
+        ++this_iter, ++b_iter) {
+      if (*this_iter > *b_iter) {
+        return true;
+      } else if (*this_iter < *b_iter) {
+        return false;
+      }
+    }
+    return false;
+  }
+}
+
+bool IndexSet::operator==(const IndexSet &b) const
+{
+  if (size() != b.size()) {
+    return false;
+  } else {
+    const_iterator this_iter = begin();
+    const_iterator b_iter = b.begin();
+    for (;(this_iter != end()) && (b_iter != b.end());
+        ++this_iter, ++b_iter) {
+      if (*this_iter != *b_iter) {
+        return false;
+      }
+    }
+    return true;
+  }
+}
+
Index: src/Fragmentation/Summation/IndexSet.hpp
===================================================================
--- src/Fragmentation/Summation/IndexSet.hpp	(revision 146c26d1db374118e51291a5034fccfd78aaee7d)
+++ src/Fragmentation/Summation/IndexSet.hpp	(revision 146c26d1db374118e51291a5034fccfd78aaee7d)
@@ -0,0 +1,53 @@
+/*
+ * IndexSet.hpp
+ *
+ *  Created on: Apr 24, 2011
+ *      Author: heber
+ */
+
+#ifndef INDEXSET_HPP_
+#define INDEXSET_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <boost/shared_ptr.hpp>
+#include <set>
+
+//!> is the type of an index
+typedef size_t Index_t;
+
+/** This class represents a single set of indices along with functions to order them
+ * and check whether one is contained in another.
+ */
+class IndexSet : public std::set<Index_t>
+{
+public:
+  //!> typedef for instance wrapped in share_ptr
+  typedef boost::shared_ptr<IndexSet> ptr;
+
+  IndexSet();
+
+  ~IndexSet();
+
+  // index set contain checks
+  bool contains(const IndexSet &_indexset) const;
+  bool contains(const Index_t _index) const;
+
+  // comparison
+  bool operator<(const IndexSet &b) const;
+  bool operator>(const IndexSet &b) const;
+  bool operator==(const IndexSet &b) const;
+  bool operator!=(const IndexSet &b) const
+  {
+    return !(*this == b);
+  }
+
+private:
+};
+
+std::ostream & operator<<(std::ostream &ost, const IndexSet &indexset);
+
+#endif /* INDEXSET_HPP_ */
Index: src/Fragmentation/Summation/Makefile.am
===================================================================
--- src/Fragmentation/Summation/Makefile.am	(revision 146c26d1db374118e51291a5034fccfd78aaee7d)
+++ src/Fragmentation/Summation/Makefile.am	(revision 146c26d1db374118e51291a5034fccfd78aaee7d)
@@ -0,0 +1,63 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+lib_LTLIBRARIES=
+TESTS =
+check_PROGRAMS =
+noinst_PROGRAMS =
+
+
+include unittests/Makefile.am
+
+FRAGMENTATIONSUMMATIONSOURCE = \
+	IndexSet.cpp
+
+FRAGMENTATIONSUMMATIONHEADER = \
+	IndexSet.hpp
+
+
+lib_LTLIBRARIES += libMolecuilderFragmentationSummation.la
+libMolecuilderFragmentationSummation_la_includedir = $(includedir)/MoleCuilder/Fragmentation/
+libMolecuilderFragmentationSummation_la_CPPFLAGS = ${BOOST_CPPFLAGS} ${CodePatterns_CFLAGS}
+libMolecuilderFragmentationSummation_la_LDFLAGS = -ldl ${BOOST_LDFLAGS}
+libMolecuilderFragmentationSummation_la_LIBADD = \
+	${CodePatterns_LIBS}
+
+
+nobase_libMolecuilderFragmentationSummation_la_include_HEADERS = ${FRAGMENTATIONSUMMATIONHEADER}
+
+## Define the source file list for the "libexample-@MOLECUILDER_API_VERSION@.la"
+## target.  Note that @MOLECUILDER_API_VERSION@ is not interpreted by Automake and
+## will therefore be treated as if it were literally part of the target name,
+## and the variable name derived from that.
+## The file extension .cc is recognized by Automake, and makes it produce
+## rules which invoke the C++ compiler to produce a libtool object file (.lo)
+## from each source file.  Note that it is not necessary to list header files
+## which are already listed elsewhere in a _HEADERS variable assignment.
+libMolecuilderFragmentationSummation_la_SOURCES = ${FRAGMENTATIONSUMMATIONSOURCE}
+
+## Instruct libtool to include ABI version information in the generated shared
+## library file (.so).  The library ABI version is defined in configure.ac, so
+## that all version information is kept in one place.
+#libMolecuilderFragmentationSummation_la_LDFLAGS = -version-info $(MOLECUILDER_SO_VERSION)
+
+## The generated configuration header is installed in its own subdirectory of
+## $(libdir).  The reason for this is that the configuration information put
+## into this header file describes the target platform the installed library
+## has been built for.  Thus the file must not be installed into a location
+## intended for architecture-independent files, as defined by the Filesystem
+## Hierarchy Standard (FHS).
+## The nodist_ prefix instructs Automake to not generate rules for including
+## the listed files in the distribution on 'make dist'.  Files that are listed
+## in _HEADERS variables are normally included in the distribution, but the
+## configuration header file is generated at configure time and should not be
+## shipped with the source tarball.
+#libMolecuilderFragmentationSummation_libincludedir = $(libdir)/MoleCuilder/include
+#nodist_libMolecuilderFragmentationSummation_libinclude_HEADERS = $(top_builddir)/libmolecuilder_config.h
+
+## Install the generated pkg-config file (.pc) into the expected location for
+## architecture-dependent package configuration information.  Occasionally,
+## pkg-config files are also used for architecture-independent data packages,
+## in which case the correct install location would be $(datadir)/pkgconfig.
+#pkgconfigdir = $(libdir)/pkgconfig
+#pkgconfig_DATA = $(top_builddir)/MoleCuilder.pc
Index: src/Fragmentation/Summation/unittests/IndexSetUnitTest.cpp
===================================================================
--- src/Fragmentation/Summation/unittests/IndexSetUnitTest.cpp	(revision 146c26d1db374118e51291a5034fccfd78aaee7d)
+++ src/Fragmentation/Summation/unittests/IndexSetUnitTest.cpp	(revision 146c26d1db374118e51291a5034fccfd78aaee7d)
@@ -0,0 +1,131 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
+ * 
+ *
+ *   This file is part of MoleCuilder.
+ *
+ *    MoleCuilder 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.
+ *
+ *    MoleCuilder 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 MoleCuilder.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * IndexSetUnitTest.cpp
+ *
+ *  Created on: Sep 16, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "Fragmentation/Summation/IndexSet.hpp"
+
+#include "IndexSetUnitTest.hpp"
+
+#include <boost/assign.hpp>
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+using namespace boost::assign;
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( IndexSetTest );
+
+
+void IndexSetTest::setUp()
+{
+  indices = new IndexSet();
+};
+
+
+void IndexSetTest::tearDown()
+{
+  delete indices;
+};
+
+/** UnitTest for contains(Index_t)
+ */
+void IndexSetTest::contains_singleIndex_Test()
+{
+  Index_t index = 1;
+  Index_t notindex = 2;
+  indices->insert(index);
+
+  CPPUNIT_ASSERT( indices->contains(index) );
+  CPPUNIT_ASSERT( !indices->contains(notindex) );
+
+  indices->erase(index);
+  CPPUNIT_ASSERT( !indices->contains(index) );
+};
+
+/** UnitTest for contains(IndexSet)
+ */
+void IndexSetTest::contains_IndexSet_Test()
+{
+  indices->insert(1);
+  IndexSet otherindices;
+  otherindices += 1,2,3;
+  IndexSet anotherindices;
+  anotherindices += 2,3,4;
+
+  // does not contain otherindices
+  CPPUNIT_ASSERT( !indices->contains(otherindices) );
+  // vice versa is true
+  CPPUNIT_ASSERT( otherindices.contains(*indices) );
+  CPPUNIT_ASSERT( !anotherindices.contains(otherindices) );
+  CPPUNIT_ASSERT( !otherindices.contains(anotherindices) );
+  // contains self
+  CPPUNIT_ASSERT( indices->contains(*indices) );
+};
+
+/** UnitTest for operator==,!=,<,>()
+ */
+void IndexSetTest::comparatorTest()
+{
+  indices->insert(1);
+  IndexSet otherindices;
+  otherindices += 1,2,3;
+  IndexSet anotherindices;
+  anotherindices += 2,3,4;
+
+  // (in)equality
+  CPPUNIT_ASSERT( *indices == *indices);
+  CPPUNIT_ASSERT( *indices != otherindices);
+  CPPUNIT_ASSERT( *indices != anotherindices);
+
+  // less than not equal
+  CPPUNIT_ASSERT( !(*indices < *indices) );
+  CPPUNIT_ASSERT( *indices < otherindices );
+  CPPUNIT_ASSERT( *indices < anotherindices );
+  CPPUNIT_ASSERT( otherindices < anotherindices );
+
+  // greater than not equal
+  CPPUNIT_ASSERT( !(*indices > *indices) );
+  CPPUNIT_ASSERT( otherindices > *indices);
+  CPPUNIT_ASSERT( anotherindices > *indices );
+  CPPUNIT_ASSERT( anotherindices > otherindices );
+};
Index: src/Fragmentation/Summation/unittests/IndexSetUnitTest.hpp
===================================================================
--- src/Fragmentation/Summation/unittests/IndexSetUnitTest.hpp	(revision 146c26d1db374118e51291a5034fccfd78aaee7d)
+++ src/Fragmentation/Summation/unittests/IndexSetUnitTest.hpp	(revision 146c26d1db374118e51291a5034fccfd78aaee7d)
@@ -0,0 +1,43 @@
+/*
+ * IndexSetUnitTest.hpp
+ *
+ *  Created on: Jun 25, 2012
+ *      Author: heber
+ */
+
+#ifndef INDEXSETUNITTEST_HPP_
+#define INDEXSETUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class IndexSet;
+
+/********************************************** Test classes **************************************/
+
+class IndexSetTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( IndexSetTest) ;
+    CPPUNIT_TEST ( contains_singleIndex_Test );
+    CPPUNIT_TEST ( contains_IndexSet_Test );
+    CPPUNIT_TEST ( comparatorTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void contains_singleIndex_Test();
+      void contains_IndexSet_Test();
+      void comparatorTest();
+
+private:
+      IndexSet *indices;
+
+};
+
+#endif /* INDEXSETUNITTEST_HPP_ */
Index: src/Fragmentation/Summation/unittests/Makefile.am
===================================================================
--- src/Fragmentation/Summation/unittests/Makefile.am	(revision 146c26d1db374118e51291a5034fccfd78aaee7d)
+++ src/Fragmentation/Summation/unittests/Makefile.am	(revision 146c26d1db374118e51291a5034fccfd78aaee7d)
@@ -0,0 +1,35 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+INCLUDES=-I$(top_srcdir)/src -I$(top_srcdir)/src/Fragmenation -I$(top_srcdir)/src/Fragmenation/Summation
+
+AM_LDFLAGS = ${CodePatterns_LIBS} $(CPPUNIT_LIBS) -ldl
+AM_CPPFLAGS = ${BOOST_CPPFLAGS} $(CPPUNIT_CFLAGS) ${CodePatterns_CFLAGS}
+
+FRAGMENTATIONSUMMATIONTESTSSOURCES = \
+	../Fragmentation/unittests/IndexSetUnitTest.cpp
+
+FRAGMENTATIONSUMMATIONTESTSHEADERS = \
+	../Fragmentation/unittests/IndexSetUnitTest.hpp
+
+FRAGMENTATIONSUMMATIONTESTS = \
+  IndexSetUnitTest
+
+TESTS += $(FRAGMENTATIONSUMMATIONTESTS)
+check_PROGRAMS += $(FRAGMENTATIONSUMMATIONTESTS) 
+noinst_PROGRAMS += $(FRAGMENTATIONSUMMATIONTESTS)
+
+FRAGMENTATIONSUMMATIONLIBS = \
+	libMolecuilderFragmentationSummation.la \
+	${CodePatterns_LIBS} \
+	$(BOOST_LIB)
+
+
+IndexSetUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	unittests/IndexSetUnitTest.cpp \
+	unittests/IndexSetUnitTest.hpp
+IndexSetUnitTest_LDADD = ${FRAGMENTATIONSUMMATIONLIBS}
+
+
+
+#AUTOMAKE_OPTIONS = parallel-tests
