00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __VECTORMAP_H__
00018 #define __VECTORMAP_H__
00019
00020 #include <vector>
00021
00022 namespace oasys {
00023
00024 template <typename _Type>
00025 class vector_map {
00026 public:
00027 typedef std::vector<_Type> EntVector;
00028
00029 vector_map() {}
00030
00031 template <typename _Predicate>
00032 bool exists(_Predicate eq) const {
00033 EntVector::const_iterator i = std::find_if(ents_.begin(), ents_.end(), eq);
00034 return i != ents_.end();
00035 }
00036
00037 template <typename _Predicate>
00038 bool insert(_Predicate eq, const _Type& type) {
00039 EntVector::iterator i = std::find_if(ents_.begin(), ents_.end(), eq);
00040 if (i == ents_.end())
00041 {
00042 ents_.push_back(type);
00043 return false;
00044 }
00045 else
00046 {
00047 *i = type;
00048 return true;
00049 }
00050 }
00051
00052 template <typename _Predicate>
00053 const Type& get(_Predicate eq) const {
00054 EntVector::const_iterator i = std::find_if(ents_.begin(), ents_.end(), eq);
00055 return *i;
00056 }
00057
00058 private:
00059 EntVector ents_;
00060 };
00061
00062 }
00063
00064 #if 1
00065
00066 #include <cstdio>
00067
00068 class Equals(int i)
00069 {
00070
00071 }
00072
00073 int
00074 main(int argc, char* argv[])
00075 {
00076 oasys::vector_map<int> vm;
00077
00078
00079 if (vm.exists(
00080 }
00081
00082 #endif
00083
00084 #endif