/*
* Project: MoleCuilder
* Description: creates and alters molecular systems
* Copyright (C) 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 .
*/
/*
* IndexSetContainer.cpp
*
* Created on: Aug 2, 2012
* Author: heber
*/
// include config.h
#ifdef HAVE_CONFIG_H
#include
#endif
#include "CodePatterns/MemDebug.hpp"
#include "IndexSetContainer.hpp"
#include "CodePatterns/Log.hpp"
#include "Fragmentation/Summation/IndexSet.hpp"
#include "Fragmentation/KeySetsContainer.hpp"
IndexSet::ptr IndexSetContainer::AllIndices(new IndexSet);
IndexSet::ptr& IndexSetContainer::createSuperSet(const KeySetsContainer &_keysets) const
{
// create superset
//IndexSet::ptr AllIndices(new IndexSet);
for (KeySetsContainer::ArrayOfIntVectors::const_iterator iter = _keysets.KeySets.begin();
iter != _keysets.KeySets.end(); ++iter)
for(KeySetsContainer::IntVector::const_iterator keyiter = (*iter).begin();
keyiter != (*iter).end(); ++keyiter) {
if (*keyiter != -1)
AllIndices->insert((Index_t)*keyiter);
}
LOG(1, "INFO: AllIndices is " << *AllIndices << ".");
return AllIndices;
}
IndexSetContainer::IndexSetContainer(const KeySetsContainer &_keysets) :
SortedVector(createSuperSet(_keysets))
{
const size_t SupersetSize = getContainer()[0]->size();
// create container with all keysets
for (KeySetsContainer::ArrayOfIntVectors::const_iterator iter = _keysets.KeySets.begin();
iter != _keysets.KeySets.end(); ++iter) {
IndexSet tempset;
for(KeySetsContainer::IntVector::const_iterator keyiter = (*iter).begin();
keyiter != (*iter).end(); ++keyiter)
if (*keyiter != -1)
tempset.insert((Index_t)*keyiter);
if (tempset.size() < SupersetSize) // only insert if not super set
insert(tempset);
}
}