activemq-cpp-3.4.0

src/main/decaf/util/Map.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef _DECAF_UTIL_MAP_H_
00019 #define _DECAF_UTIL_MAP_H_
00020 
00021 #include <functional>
00022 #include <vector>
00023 #include <decaf/lang/exceptions/UnsupportedOperationException.h>
00024 #include <decaf/util/NoSuchElementException.h>
00025 #include <decaf/util/concurrent/Synchronizable.h>
00026 #include <decaf/util/concurrent/Mutex.h>
00027 
00028 namespace decaf{
00029 namespace util{
00030 
00036     template <typename K, typename V, typename COMPARATOR = std::less<K> >
00037     class Map : public concurrent::Synchronizable {
00038     public:
00039 
00040         class Entry {
00041         private:
00042 
00043             K key;
00044             V value;
00045 
00046         public:
00047 
00048             Entry() {}
00049             virtual ~Entry() {}
00050 
00051             virtual const K& getKey() const = 0;
00052 
00053             virtual const V& getValue() const = 0;
00054 
00055             virtual void setValue( const V& value ) = 0;
00056 
00057         };
00058 
00059     public:
00060 
00064         Map() {}
00065 
00066         virtual ~Map() {}
00067 
00074         virtual bool equals( const Map& source ) const = 0;
00075 
00081         virtual void copy( const Map& source ) = 0;
00082 
00087         virtual void clear() = 0;
00088 
00095         virtual bool containsKey( const K& key ) const = 0;
00096 
00104         virtual bool containsValue( const V& value ) const = 0;
00105 
00109         virtual bool isEmpty() const = 0;
00110 
00114         virtual int size() const = 0;
00115 
00126         virtual V& get( const K& key ) = 0;
00127 
00138         virtual const V& get( const K& key ) const = 0;
00139 
00147         virtual void put( const K& key, const V& value ) = 0;
00148 
00158         virtual void putAll( const Map<K,V,COMPARATOR>& other ) = 0;
00159 
00170         virtual V remove( const K& key ) = 0;
00171 
00182         // TODO
00183 
00187         virtual std::vector<K> keySet() const = 0;
00188 
00192         virtual std::vector<V> values() const = 0;
00193 
00194     };
00195 
00196 }}
00197 
00198 #endif /*_DECAF_UTIL_MAP_H_*/