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 00035 class TrellisPathList 00036 { 00037 protected: 00038 std::list<const TrellisPath*> m_collection; 00039 public: 00040 // iters 00041 typedef std::list<const TrellisPath*>::iterator iterator; 00042 typedef std::list<const TrellisPath*>::const_iterator const_iterator; 00043 00044 iterator begin() { 00045 return m_collection.begin(); 00046 } 00047 iterator end() { 00048 return m_collection.end(); 00049 } 00050 const_iterator begin() const { 00051 return m_collection.begin(); 00052 } 00053 const_iterator end() const { 00054 return m_collection.end(); 00055 } 00056 00057 ~TrellisPathList() { 00058 // clean up 00059 RemoveAllInColl(m_collection); 00060 } 00061 00063 void Add(TrellisPath *trellisPath) { 00064 m_collection.push_back(trellisPath); 00065 } 00066 00067 const TrellisPath *pop() { 00068 const TrellisPath *top = m_collection.front(); 00069 00070 // Detach 00071 m_collection.pop_front(); 00072 return top; 00073 } 00074 00075 size_t GetSize() const { 00076 return m_collection.size(); 00077 } 00078 00079 const TrellisPath at(size_t position) const { 00080 const_iterator iter = m_collection.begin(); 00081 for(size_t i = position; i>0; i--) { 00082 iter++; 00083 } 00084 return **iter; 00085 } 00086 }; 00087 00088 } 00089 00090 #endif