⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vmhashtable.h

📁 TOOL (Tiny Object Oriented Language) is an easily-embedded, object-oriented, C++-like-language inter
💻 H
字号:
#ifndef VMHASHTABLE_H_INCLUDED
#define VMHASHTABLE_H_INCLUDED
/*****************************************************************************/
/*                              HEADER FILE                                  */
/*****************************************************************************/
/*
       $Archive:   $

      $Revision:   $
          $Date:   $
        $Author:   $

    Description:   Declaration of the VMHashTable class

                      TOOL And XML FORMS License
                      ==========================

                      Except where otherwise noted, all of the documentation 
                      and software included in the TOOL package is 
                      copyrighted by Michael Swartzendruber.

                      Copyright (C) 2005 Michael John Swartzendruber. 
                      All rights reserved.

                      Access to this code, whether intentional or accidental,
                      does NOT IMPLY any transfer of rights.

                      This software is provided "as-is," without any express 
                      or implied warranty. In no event shall the author be held
                      liable for any damages arising from the use of this software.

                      Permission is granted to anyone to use this software for 
                      any purpose, including commercial applications, and to 
                      alter and redistribute it, provided that the following 
                      conditions are met:

                      1. All redistributions of source code files must retain 
                         all copyright notices that are currently in place, 
                         and this list of conditions without modification.

                      2. The origin of this software must not be misrepresented;
                         you must not claim that you wrote the original software.

                      3. If you use this software in another product, an acknowledgment
                         in the product documentation would be appreciated but is
                         not required.

                      4. Modified versions in source or binary form must be plainly 
                         marked as such, and must not be misrepresented as being 
                         the original software.
*/
/*****************************************************************************/


#include <stddef.h>
#include "../VMCoreGlobal.h"
#include "VMHashBucket.h"


size_t VMHashFunction( int                iToHash,   size_t iBuckets );
size_t VMHashFunction( unsigned int       uiToHash,  size_t iBuckets );
size_t VMHashFunction( long               lToHash,   size_t iBuckets );
size_t VMHashFunction( unsigned long      ulToHash,  size_t iBuckets );
size_t VMHashFunction( const char*        pchToHash, size_t iBuckets );
size_t VMHashFunction( const VMVariant&   xToHash,   size_t iBuckets );


const int ciNumBuckets = 43;

class VMHashTable
{
friend
  class VMHashTableIterator;

public:
  VMHashTable( void );
  VMHashTable( const VMHashTable& ht );
  ~VMHashTable( void );

  void operator = ( const VMHashTable& ht );

  void Insert( const VMVariant& kx, const VMVariant& dx );

  bool Delete( const VMVariant& kx );

  bool Holds( const VMVariant& kx ) const;

  bool LookUp( const VMVariant& kx, VMVariant& roOut ) const;

  void Traverse( void (*func) (const VMVariant& kx,const VMVariant& dx ) );

  size_t GetCount( void ) const;
  size_t GetNumBuck( void ) const;

  void Erase( void );

  void DeepCopy( const VMHashTable& ht );

protected:
  size_t           Count;
  size_t           LockCount;
  VMHashBucket     Bucket[ ciNumBuckets ];
};



class VMHashTableIterator
{
public:
  VMHashTableIterator( const VMHashTable& d );
  VMHashTableIterator( const VMHashTableIterator& iter );
  ~VMHashTableIterator( void );

  void operator = ( const VMHashTableIterator & iter );

  bool operator ++ ( void );

  void Reset();

  VMVariant& GetData( void );
  VMVariant& GetKey( void );

protected:
  VMHashTable*  Dict;
  size_t        Bno;
};


#endif

/*****************************************************************************/
/* Check-in history */
/*
 *$Log:  $
*/
/*****************************************************************************/


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -