tSearchableStack.h
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of FZIs ic_workspace.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00012 //
00013 // -- END LICENSE BLOCK ------------------------------------------------
00014 
00015 //----------------------------------------------------------------------
00025 //----------------------------------------------------------------------
00026 #ifndef ICL_CORE_T_SEARCHABLE_STACK_H_INCLUDED
00027 #define ICL_CORE_T_SEARCHABLE_STACK_H_INCLUDED
00028 
00029 #include <functional>
00030 #include <vector>
00031 
00032 #include "icl_core/BaseTypes.h"
00033 #include "icl_core/Deprecate.h"
00034 #include "icl_core/TemplateHelper.h"
00035 
00036 namespace icl_core {
00037 
00042 template <typename T, typename Compare = std::equal_to<T>, typename Alloc = std::allocator<T> >
00043 class ICL_CORE_VC_DEPRECATE tSearchableStack : protected std::vector<T, Alloc>
00044 {
00045 public:
00049   typedef typename std::vector<T>::const_iterator const_iterator;
00051   typedef typename std::vector<T>::const_reverse_iterator const_reverse_iterator;
00053   typedef typename std::vector<T>::size_type size_type;
00054 
00056   tSearchableStack() : std::vector<T, Alloc>(), m_comp() { }
00057 
00059   void clear() { std::vector<T, Alloc>::clear(); }
00061   bool empty() const { return std::vector<T, Alloc>::empty(); }
00063   size_type size() const { return std::vector<T, Alloc>::size(); }
00064 
00066   void push(typename ConvertToRef<T>::ToConstRef t) { std::vector<T, Alloc>::push_back(t); }
00068   void pop() { std::vector<T, Alloc>::pop_back(); }
00070   typename ConvertToRef<T>::ToRef top() { return std::vector<T, Alloc>::back(); }
00072   typename ConvertToRef<T>::ToConstRef top() const { return std::vector<T, Alloc>::back(); }
00073 
00075   const_iterator begin() const { return std::vector<T, Alloc>::begin(); }
00077   const_iterator end() const { return std::vector<T, Alloc>::end(); }
00079   const_reverse_iterator rbegin() const { return std::vector<T, Alloc>::rbegin(); }
00081   const_reverse_iterator rend() const { return std::vector<T, Alloc>::rend(); }
00082 
00084   const_iterator find(typename ConvertToRef<T>::ToConstRef t) const
00085   {
00086     for (const_iterator it = begin(); it != end(); ++it)
00087     {
00088       if (m_comp(*it, t)) { return it; }
00089     }
00090     return end();
00091   }
00092 
00093   Compare m_comp;
00094 } ICL_CORE_GCC_DEPRECATE;
00095 
00096 typedef tSearchableStack<tUnsigned8> tUnsigned8SearchableStack;
00097 typedef tSearchableStack<tUnsigned16> tUnsigned16SearchableStack;
00098 typedef tSearchableStack<tUnsigned32> tUnsigned32SearchableStack;
00099 typedef tSearchableStack<tUnsigned64> tUnsigned64SearchableStack;
00100 typedef tSearchableStack<tSigned8> tSigned8SearchableStack;
00101 typedef tSearchableStack<tSigned16> tSigned16SearchableStack;
00102 typedef tSearchableStack<tSigned32> tSigned32SearchableStack;
00103 typedef tSearchableStack<tSigned64> tSigned64SearchableStack;
00104 typedef tSearchableStack<tFloat> tFloatSearchableStack;
00105 typedef tSearchableStack<tDouble> tDoubleSearchableStack;
00106 
00107 }
00108 
00109 #endif


fzi_icl_core
Author(s):
autogenerated on Thu Jun 6 2019 20:22:24