Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_map.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Teuchos: Common Tools Package
4//
5// Copyright 2004 NTESS and the Teuchos contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef TEUCHOS_MAP_H
11#define TEUCHOS_MAP_H
12
18#ifndef TFLOP
19# include <map>
20#endif // NOT TFLOP
21
33namespace Teuchos {
34
35#ifdef TFLOP
36
37template<class Key, class T>
38class std::map {
39public:
40 typedef Key key_type;
41 typedef T mapped_type;
42 typedef std::pair<Key,T> value_type;
43 typedef std::list<value_type> list_t;
44 typedef typename list_t::iterator iterator;
45 typedef typename list_t::const_iterator const_iterator;
46
48
49
51 std::map() {}
52
54 std::map( const std::map<Key,T>& map_in ) : list_( map_in.list_ ) {}
55
57 virtual ~std::map() {}
59
61
62
64 iterator begin() { return list_.begin(); }
65
67 const_iterator begin() const { return list_.begin(); }
68
70 iterator end() { return list_.end(); }
71
73 const_iterator end() const { return list_.end(); }
74
76
80 mapped_type& operator[]( const key_type& k )
81 {
82 iterator itr = find(k);
83 if(itr != end()) return (*itr).second;
84 list_.push_back( value_type( k, T() ) );
85 return list_.back().second;
86 }
88
90
91
93
97 iterator find(const key_type& k)
98 {
99 for( iterator itr = begin(); itr != end(); ++itr ) {
100 if( (*itr).first == k ) {
101 return itr;
102 }
103 }
104 return end();
105 }
106
108
112 const_iterator find(const key_type& k) const
113 {
114 for( const_iterator itr = begin(); itr != end(); ++itr ) {
115 if( (*itr).first == k ) {
116 return itr;
117 }
118 }
119 return end();
120 }
121
122 bool empty() const { return list_.empty(); }
123
125private:
126 list_t list_;
127};
128
129#else
130
131using std::map;
132
133#endif
134
135} // namespace Teuchos
136
137#endif // TEUCHOS_MAP_H
Teuchos header file which uses auto-configuration information to include necessary C++ headers.
This class creates a basic std::map object for platforms where the std::map is deficient,...
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...