aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/common/src/hash_container.h
diff options
context:
space:
mode:
authorGravatar ShizZy <shizzy@6bit.net>2013-09-04 17:52:59 -0400
committerGravatar ShizZy <shizzy@6bit.net>2013-09-04 17:52:59 -0400
commit72325bef1d6d1e70f308e64bf7d764f9fd2abbc4 (patch)
treeaa6ce8e1e769e47f435fe8ef9b1561ced9c81483 /src/common/src/hash_container.h
parent27474060e1287a67c45cd790d29b9095b35b2bdf (diff)
deleted gekko's common files
Diffstat (limited to 'src/common/src/hash_container.h')
-rw-r--r--src/common/src/hash_container.h116
1 files changed, 0 insertions, 116 deletions
diff --git a/src/common/src/hash_container.h b/src/common/src/hash_container.h
deleted file mode 100644
index ab832f3c..00000000
--- a/src/common/src/hash_container.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- * Copyright (C) 2005-2012 Gekko Emulator
- *
- * @file hash_container.h
- * @author ShizZy <shizzy@6bit.net>
- * @date 2012-11-29
- * @brief Container object for storing a hash lookup
- *
- * @section LICENSE
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details at
- * http://www.gnu.org/copyleft/gpl.html
- *
- * Official project repository can be found at:
- * http://code.google.com/p/gekko-gc-emu/
- */
-
-#ifndef COMMON_HASH_CONTAINER_H_
-#define COMMON_HASH_CONTAINER_H_
-
-#include <map>
-#include "common.h"
-
-/// Hash container generic interface - Don't use directly, use a derived class
-template <class HashType, class ValueType> class HashContainer {
- /**
- * Add (or update if already exists) a value at the specified hash in the container
- * @param hash Hash to use
- * @param value Value to update at given hash in the container
- */
- ValueType* Update(HashType hash, ValueType value);
-
- /**
- * Remove a hash entry in the hash container
- * @param hash Hash value of entry to remove
- */
- void Remove(HashType hash);
-
- /**
- * Fetch the value at at the given hash from the hash container
- * @param hash Hash value of entry to fetch
- * @return Pointer to value stored at hash location on success (index was found), otherwise NULL
- */
- ValueType* FetchFromHash(HashType hash);
-
- /**
- * Fetch the value at at the given integer index from the hash container
- * @param hash Hash value of entry to fetch
- * @return Pointer to value stored at hash location on success (index was found), otherwise NULL
- */
- ValueType* FetchFromIndex(int index);
-
- /**
- * Get the size of the hash container
- * @return Number of elements in the hash container
- */
- int Size();
-};
-
-/// Hash container implemented using STL map
-template <class HashType, class ValueType> class HashContainer_STLMap :
- public HashContainer<HashType, ValueType> {
-
-public:
- HashContainer_STLMap() {
- }
- ~HashContainer_STLMap() {
- }
-
- ValueType* Update(HashType hash, ValueType value) {
- map_[hash] = value;
- return &map_[hash];
- }
-
- void Remove(HashType hash) {
- map_.erase(hash);
- }
-
- ValueType* FetchFromHash(HashType hash) {
- typename std::map<HashType, ValueType>::iterator itr = map_.find(hash);
- if (itr == map_.end()) {
- return NULL;
- }
- return &itr->second;
- }
-
- ValueType* FetchFromIndex(int index) {
- typename std::map<HashType, ValueType>::iterator itr = map_.begin();
- int i = 0;
- for (; i < index; ++i) {
- ++itr;
- }
- if (i < index) {
- return NULL;
- }
- return &itr->second;
- }
-
- int Size() {
- return static_cast<int>(map_.size());
- }
-
-private:
- std::map<HashType, ValueType> map_;
-
- DISALLOW_COPY_AND_ASSIGN(HashContainer_STLMap);
-};
-
-#endif // COMMON_HASH_CONTAINER_H_