Replace MapWrapper with std::map<>.

MapWrapper was needed on some platforms where STL wasn't supported, we
now use std::map<> directly.

BUG=2164
TEST=trybots
R=henrike@webrtc.org, phoglund@webrtc.org, stefan@webrtc.org, wu@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2001004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4530 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org
2013-08-12 19:51:57 +00:00
parent dd14b2add1
commit 4ca7d3f9fe
34 changed files with 342 additions and 1295 deletions

View File

@ -1,75 +0,0 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_MAP_WRAPPER_H_
#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_MAP_WRAPPER_H_
#include <map>
#include "webrtc/system_wrappers/interface/constructor_magic.h"
namespace webrtc {
class MapItem {
public:
MapItem(int id, void* ptr);
virtual ~MapItem();
void* GetItem();
int GetId();
unsigned int GetUnsignedId();
void SetItem(void* ptr);
private:
friend class MapWrapper;
int item_id_;
void* item_pointer_;
};
class MapWrapper {
public:
MapWrapper();
~MapWrapper();
// Puts a pointer to anything in the map and associates it with id. Note, id
// needs to be unique for all items in the map.
int Insert(int id, void* ptr);
// Removes item from map.
int Erase(MapItem* item);
// Finds item with associated with id and removes it from the map.
int Erase(int id);
// Returns the number of elements stored in the map.
int Size() const;
// Returns a pointer to the first MapItem in the map.
MapItem* First() const;
// Returns a pointer to the last MapItem in the map.
MapItem* Last() const;
// Returns a pointer to the MapItem stored after item in the map.
MapItem* Next(MapItem* item) const;
// Returns a pointer to the MapItem stored before item in the map.
MapItem* Previous(MapItem* item) const;
// Returns a pointer to the MapItem associated with id from the map.
MapItem* Find(int id) const;
private:
std::map<int, MapItem*> map_;
};
} // namespace webrtc
#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_MAP_WRAPPER_H_