src/Sim/Op/OpContainer/OpList.cpp

説明を見る。
00001 // 
00002 // Copyright (c) 2005-2008 Kenichi Watanabe.
00003 // Copyright (c) 2005-2008 Yasuhiro Watari.
00004 // Copyright (c) 2005-2008 Hironori Ichibayashi.
00005 // Copyright (c) 2008-2009 Kazuo Horio.
00006 // Copyright (c) 2009-2013 Naruki Kurata.
00007 // Copyright (c) 2005-2013 Ryota Shioya.
00008 // Copyright (c) 2005-2013 Masahiro Goshima.
00009 // 
00010 // This software is provided 'as-is', without any express or implied
00011 // warranty. In no event will the authors be held liable for any damages
00012 // arising from the use of this software.
00013 // 
00014 // Permission is granted to anyone to use this software for any purpose,
00015 // including commercial applications, and to alter it and redistribute it
00016 // freely, subject to the following restrictions:
00017 // 
00018 // 1. The origin of this software must not be misrepresented; you must not
00019 // claim that you wrote the original software. If you use this software
00020 // in a product, an acknowledgment in the product documentation would be
00021 // appreciated but is not required.
00022 // 
00023 // 2. Altered source versions must be plainly marked as such, and must not be
00024 // misrepresented as being the original software.
00025 // 
00026 // 3. This notice may not be removed or altered from any source
00027 // distribution.
00028 // 
00029 // 
00030 
00031 
00032 #include <pch.h>
00033 #include "Sim/Op/OpContainer/OpList.h"
00034 #include "Sim/Op/Op.h"
00035 
00036 using namespace Onikiri;
00037 
00038 OpList::OpList()
00039 {
00040 }
00041 
00042 OpList::OpList( const OpArray& opArray )
00043 {
00044     resize( opArray );
00045 }
00046 
00047 void OpList::resize( const OpArray& opArray )
00048 {
00049     resize( opArray.GetCapacity() );
00050 }
00051 
00052 void OpList::resize( int capacity )
00053 {
00054     alive_table.resize( capacity, false );
00055     iterator_table.resize( capacity );
00056 }
00057 
00058 OpList::~OpList()
00059 {
00060 }
00061 
00062 OpList::iterator OpList::get_iterator( const OpIterator& opIterator ) const
00063 {
00064     return iterator_table[ opIterator.GetID() ];
00065 }
00066 
00067 OpList::iterator OpList::operator[]( const OpIterator& opIterator ) const
00068 {
00069     return get_iterator( opIterator );
00070 }
00071 
00072 OpList::iterator OpList::insert( iterator pos, const OpIterator& opIterator )
00073 {
00074     OpArray::ID id     = opIterator.GetID();
00075 
00076     ASSERT(
00077         alive_table[ id ] == false, 
00078         "opIterator inserted twice."
00079     );
00080     
00081     iterator iter = 
00082         list_type::insert( pos, opIterator );
00083 
00084     iterator_table[ id ] = iter;
00085     alive_table[ id ] = true;
00086 
00087     return iter;
00088 }
00089 
00090 OpList::iterator OpList::erase( const OpIterator& opIterator )
00091 {
00092     return erase( get_iterator(opIterator) );
00093 }
00094 
00095 OpList::iterator OpList::erase( iterator pos )
00096 {
00097     // x handle  insert A
00098     // erase  m_iteratorTable Yvf
00099     OpArray::ID     id     = pos->GetID();
00100 
00101     alive_table[ id ] = false;
00102     iterator_table[ id ] = end();
00103     
00104     return list_type::erase( pos );
00105 }
00106 
00107 void OpList::clear()
00108 {
00109     list_type::clear();
00110     alive_table.reset();
00111 }
00112 
00113 OpList::iterator OpList::find( const OpIterator& opIterator )
00114 {
00115     if( alive_table[ opIterator.GetID() ] == true ) {
00116         return get_iterator(opIterator);
00117     }else {
00118         return list_type::end();
00119     }
00120 }
00121 
00122 size_t OpList::count( const OpIterator& op ) const
00123 {
00124     if( alive_table[ op.GetID() ] == true ) {
00125         return 1;
00126     }else {
00127         return 0;
00128     }
00129 }
00130 
00131 bool OpList::find_and_erase( OpIterator op )
00132 {
00133     iterator i = find(op);
00134     bool erased = i != end();
00135     if(erased){
00136         erase(i);
00137     }
00138     return erased;
00139 }
00140 
00141 void OpList::push_inorder( OpIterator op )
00142 {
00143     // push_backI
00144     if(empty()) {
00145         push_back(op);
00146         return;
00147     }
00148 
00149     // opSerialIDOpIterator
00150     iterator iter = end();
00151     u64 id = op->GetGlobalSerialID();
00152     do {
00153         --iter;
00154         if( (*iter)->GetGlobalSerialID() < id ) {
00155             // OpIteratorop}
00156             // insert wvfO}1CNg
00157             ++iter;
00158             insert(iter, op);
00159             return;
00160         }
00161     } while( iter != begin() );
00162     
00163     // B
00164     push_front(op);
00165 }
00166 

Onikiri2に対してTue Jun 18 14:34:24 2013に生成されました。  doxygen 1.4.7