00001 // $Id$ 00002 00003 /*********************************************************************** 00004 Moses - factored phrase-based language decoder 00005 Copyright (C) 2006 University of Edinburgh 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2.1 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 ***********************************************************************/ 00021 00022 #ifndef moses_TrellisPathList_h 00023 #define moses_TrellisPathList_h 00024 00025 #include <list> 00026 #include <set> 00027 #include "TrellisPath.h" 00028 00029 namespace Moses 00030 { 00031 00033 class TrellisPathList 00034 { 00035 protected: 00036 std::list<const TrellisPath*> m_collection; 00037 public: 00038 // iters 00039 typedef std::list<const TrellisPath*>::iterator iterator; 00040 typedef std::list<const TrellisPath*>::const_iterator const_iterator; 00041 00042 iterator begin() { 00043 return m_collection.begin(); 00044 } 00045 iterator end() { 00046 return m_collection.end(); 00047 } 00048 const_iterator begin() const { 00049 return m_collection.begin(); 00050 } 00051 const_iterator end() const { 00052 return m_collection.end(); 00053 } 00054 00055 ~TrellisPathList() { 00056 // clean up 00057 RemoveAllInColl(m_collection); 00058 } 00059 00061 void Add(TrellisPath *trellisPath) { 00062 m_collection.push_back(trellisPath); 00063 } 00064 00065 const TrellisPath *pop() { 00066 const TrellisPath *top = m_collection.front(); 00067 00068 // Detach 00069 m_collection.pop_front(); 00070 return top; 00071 } 00072 00073 size_t GetSize() const { 00074 return m_collection.size(); 00075 } 00076 00077 const TrellisPath at(size_t position) const { 00078 const_iterator iter = m_collection.begin(); 00079 for(size_t i = position; i>0; i--) { 00080 iter++; 00081 } 00082 return **iter; 00083 } 00084 }; 00085 00086 } 00087 00088 #endif
1.5.9