the_Foundation 1.0
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
blockhash.h File Reference
#include "hash.h"
#include "block.h"
#include "object.h"

Data Structures

struct  iBlockHashNodeClass
 
struct  iBlockHashNode
 
struct  iBlockHashClass
 
struct  iBlockHash
 
struct  iBlockHashReverseIterator
 
struct  iBlockHashReverseConstIterator
 

Macros

#define size_BlockHash(d)   size_Hash(&(d)->hash)
 
#define isEmpty_BlockHash(d)   isEmpty_Hash(&(d)->hash)
 
#define iDeclareBlockHash(typeName, keyType, valueType)
 
#define iDefineBlockHash(typeName, keyType, valueType)
 
#define iDefinePlainKeyBlockHash(typeName, keyType, valueType)
 

Functions

iBlockHash * new_BlockHash (void)
 
void init_BlockHash (iBlockHash *d)
 
void deinit_BlockHash (iBlockHash *d)
 
void setNodeClass_BlockHash (iBlockHash *, const iBlockHashNodeClass *nodeClass)
 
iBool contains_BlockHash (const iBlockHash *, const iBlock *key)
 
const iAnyObject * constValue_BlockHash (const iBlockHash *, const iBlock *key)
 
iAnyObject * value_BlockHash (iBlockHash *, const iBlock *key)
 
void clear_BlockHash (iBlockHash *)
 
iBool insert_BlockHash (iBlockHash *, const iBlock *key, const iAnyObject *value)
 
iBool remove_BlockHash (iBlockHash *, const iBlock *key)
 
void insertValues_BlockHash (iBlockHash *, const iBlock *key, const iAnyObject *value,...)
 
void insertValuesCStr_BlockHash (iBlockHash *, const char *key, const iAnyObject *value,...)
 
Iterators
void init_BlockHashIterator (iBlockHashIterator *, iBlockHash *)
 
void next_BlockHashIterator (iBlockHashIterator *)
 
void init_BlockHashReverseIterator (iBlockHashReverseIterator *, iBlockHash *)
 
void next_BlockHashReverseIterator (iBlockHashReverseIterator *)
 
const iBlock * key_BlockHashIterator (iBlockHashIterator *)
 
void remove_BlockHashIterator (iBlockHashIterator *)
 
void init_BlockHashConstIterator (iBlockHashConstIterator *, const iBlockHash *)
 
void next_BlockHashConstIterator (iBlockHashConstIterator *)
 
void init_BlockHashReverseConstIterator (iBlockHashReverseConstIterator *, const iBlockHash *)
 
void next_BlockHashReverseConstIterator (iBlockHashReverseConstIterator *)
 
const iBlock * key_BlockHashConstIterator (iBlockHashConstIterator *)
 

Variables

iBlockHashClass Class_BlockHash
 

BlockHashNode

#define key_BlockHashNode(d)   iConstCast(iBlock *, (&((const iBlockHashNode *) (d))->keyBlock))
 
iBlockHashNodeClass Class_BlockHashNode
 
iBlockHashNode * new_BlockHashNode (const iBlock *key, const iAnyObject *object)
 
iHashKey hashKey_BlockHashNode (const iBlock *key)
 
void deinit_BlockHashNode (iBlockHashNode *)
 

Detailed Description

Hash object that uses Block for keys and Object for values.

Authors
Copyright (c) 2017 Jaakko Keränen jaakk.nosp@m.o.ke.nosp@m.ranen.nosp@m.@iki.nosp@m..fi
License

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ iDefineBlockHash

#define iDefineBlockHash (   typeName,
  keyType,
  valueType 
)

Functions that must be defined manually:

  • key_<typeName>Node(d): returns the key as-is (if available)
  • initKey_<typeName>Node(d, key): copies the Block back to an existing keyType instance
  • initBlock_<typeName>Key(key, block): initializes a Block with the key data

◆ iDefinePlainKeyBlockHash

#define iDefinePlainKeyBlockHash (   typeName,
  keyType,
  valueType 
)
Value:
iDefineBlockHash(typeName, keyType, valueType) \
\
const i##keyType *key_##typeName##Node(const i##typeName##Node *d) { \
return constData_Block(&d->keyBlock); \
} \
\
void initKey_##typeName##Node(const i##typeName##Node *d, i##keyType *key) { \
iAssert(size_Block(&d->keyBlock) == sizeof(i##keyType)); \
memcpy(key, constData_Block(&d->keyBlock), sizeof(i##keyType)); \
} \
\
void initBlock_##typeName##Key(const i##keyType *d, iBlock *block) { \
initData_Block(block, d, sizeof(i##keyType)); \
}
#define iDefineBlockHash(typeName, keyType, valueType)
Definition blockhash.h:172

Function Documentation

◆ insert_BlockHash()

iBool insert_BlockHash ( iBlockHash *  ,
const iBlock *  key,
const iAnyObject *  value 
)

Inserts a key-value node into the BlockHash.

Parameters
keyKey string. A copy is made of the key and stored in the node.
valueValue object.
Returns
iTrue, if the a new key-value node was added and the size of the hash increased as a result. False, if an existing one was replaced.