Copyright 2010, SIL International All rights reserved.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of License, or (at your option) any later version.
This program 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 Lesser General Public License for more details.
You should also have received a copy of the GNU Lesser General Public License along with this library in the file named "LICENSE". If not, write to the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA or visit their web page on the internet at http://www.fsf.org/licenses/lgpl.html.
Alternatively, the contents of this file may be used under the terms of the Mozilla Public License (http://mozilla.org/MPL) or 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.
*/
// designed to have a limited subset of the std::vector api #pragma once
template <typename T> class Vector
{
T * m_first, *m_last, *m_end; public: typedef T & reference; typedefconst T & const_reference; typedef T * iterator; typedefconst T * const_iterator;
template <typename T> inline void Vector<T>::resize(size_t n, const T & v) { const ptrdiff_t d = n-size(); if (d < 0) erase(end()+d, end()); elseif (d > 0) insert(end(), d, v);
}
template<typename T> inline typename Vector<T>::iterator Vector<T>::_insert_default(iterator p, size_t n)
{
assert(begin() <= p && p <= end()); const ptrdiff_t i = p - begin();
reserve(((size() + n + 7) >> 3) << 3);
p = begin() + i; // Move tail if there is one if (p != end()) memmove(p + n, p, distance(p,end())*sizeof(T));
m_last += n; return p;
}
template<typename T> inline void Vector<T>::insert(iterator p, size_t n, const T & x)
{
p = _insert_default(p, n); // Copy in elements for (; n; --n, ++p) { new (p) T(x); }
}
template<typename T> inline void Vector<T>::insert(iterator p, const_iterator first, const_iterator last)
{
p = _insert_default(p, distance(first, last)); // Copy in elements for (;first != last; ++first, ++p) { new (p) T(*first); }
}
template<typename T> inline typename Vector<T>::iterator Vector<T>::erase(iterator first, iterator last)
{ for (iterator e = first; e != last; ++e) e->~T(); const size_t sz = distance(first, last); if (m_last != last) memmove(first, last, distance(last,end())*sizeof(T));
m_last -= sz; return first;
}
} // namespace graphite2
Messung V0.5
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.