00001 #ifndef MST_CACHE_CPP 00002 #define MST_CACHE_CPP 00003 00004 //-------------------------------------------------------------------- 00005 // 00006 // This file is part of PEACE. 00007 // 00008 // PEACE is free software: you can redistribute it and/or modify it 00009 // under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation, either version 3 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // PEACE is distributed in the hope that it will be useful, but 00014 // WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with PEACE. If not, see <http://www.gnu.org/licenses/>. 00020 // 00021 // Miami University makes no representations or warranties about the 00022 // suitability of the software, either express or implied, including 00023 // but not limited to the implied warranties of merchantability, 00024 // fitness for a particular purpose, or non-infringement. Miami 00025 // University shall not be liable for any damages suffered by licensee 00026 // as a result of using, result of using, modifying or distributing 00027 // this software or its derivatives. 00028 // 00029 // By using or copying this Software, Licensee agrees to abide by the 00030 // intellectual property laws, and all other applicable laws of the 00031 // U.S., and the terms of GNU General Public License (version 3). 00032 // 00033 // Authors: Dhananjai M. Rao raodm@muohio.edu 00034 // 00035 //--------------------------------------------------------------------- 00036 00037 #include "MSTCache.h" 00038 #include "Utilities.h" 00039 #include <algorithm> 00040 #include <iterator> 00041 00042 MSTCache::MSTCache(const int totalESTCount, const int startESTidx, 00043 const int numberOfOwnESTs, 00044 const ESTAnalyzer *estAnalyzer, 00045 const bool repopulate, const int maxCacheSize) : 00046 analyzer(estAnalyzer), nodesAdded(totalESTCount, false), 00047 startOwnESTidx(startESTidx), numOwnESTs(numberOfOwnESTs), 00048 maxCachePerEST(maxCacheSize), repopulateCaches(repopulate) { 00049 // Nothing else to be done for now in the constructor. 00050 } 00051 00052 // static utility method 00053 void 00054 MSTCache::copy_n(const SMList& input, const size_t count, SMList &output) { 00055 // Get minimum of input.size() or count to ensure we never exceed 00056 // the number of elements in input list. 00057 const size_t stopIndex = (count < input.size()) ? count : input.size(); 00058 // Copy the necessary elements from input to output... 00059 for(size_t index = 0; (index < stopIndex); index++) { 00060 output.push_back(input[index]); 00061 } 00062 } 00063 00064 #endif