usermode/library/common/chhash.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2011 Computer Sciences Department, 
00003     University of Wisconsin -- Madison
00004 
00005     ----------------------------------------------------------------------
00006 
00007     This file is part of Mnemosyne: Lightweight Persistent Memory, 
00008     originally developed at the University of Wisconsin -- Madison.
00009 
00010     Mnemosyne was originally developed primarily by Haris Volos
00011     with contributions from Andres Jaan Tack.
00012 
00013     ----------------------------------------------------------------------
00014 
00015     Mnemosyne is free software; you can redistribute it and/or
00016     modify it under the terms of the GNU General Public License
00017     as published by the Free Software Foundation, version 2
00018     of the License.
00019  
00020     Mnemosyne is distributed in the hope that it will be useful,
00021     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023     GNU General Public License for more details.
00024 
00025     You should have received a copy of the GNU General Public License
00026     along with this program; if not, write to the Free Software
00027     Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00028     Boston, MA  02110-1301, USA.
00029 
00030 ### END HEADER ###
00031 */
00032 
00039 #ifndef _M_HASH_H
00040 #define _M_HASH_H
00041 
00042 #include "mtypes.h"
00043 #include "result.h"
00044 
00045 #define HASH_FACTOR 4
00046 
00047 /* Opaque structure used to represent hash table. */
00048 typedef struct m_chhash_s m_chhash_t;
00049 
00050 /* Opaque structure used to represent hash table iterator. */
00051 typedef struct m_chhash_iter_s m_chhash_iter_t;
00052 
00053 typedef uintptr_t m_chhash_key_t;
00054 typedef void *m_chhash_value_t;
00055 typedef struct m_chhash_bucket_s m_chhash_bucket_t;
00056 
00057 struct m_chhash_iter_s {
00058         m_chhash_t        *chhash;
00059         unsigned int      index;
00060         m_chhash_bucket_t *bucket;
00061 };
00062 
00063 
00064 m_result_t m_chhash_create(m_chhash_t**, unsigned int, bool);
00065 m_result_t m_chhash_destroy(m_chhash_t**);
00066 m_result_t m_chhash_add(m_chhash_t*, m_chhash_key_t, m_chhash_value_t);
00067 m_result_t m_chhash_lookup(m_chhash_t*, m_chhash_key_t, m_chhash_value_t *);
00068 m_result_t m_chhash_remove(m_chhash_t*, m_chhash_key_t, m_chhash_value_t *);
00069 void m_chhash_iter_init(m_chhash_t *chhash, m_chhash_iter_t *iter);
00070 m_result_t m_chhash_iter_next(m_chhash_iter_t *iter, m_chhash_key_t *key, m_chhash_value_t *value);
00071 void m_chhash_print(m_chhash_t *);
00072 #endif

Generated on Sat Apr 23 11:43:34 2011 for Mnemosyne by  doxygen 1.4.7