OSDN Git Service

(none)
authorryuz <ryuz>
Mon, 31 Aug 2009 22:07:24 +0000 (22:07 +0000)
committerryuz <ryuz>
Mon, 31 Aug 2009 22:07:24 +0000 (22:07 +0000)
aplfw/library/container/hashtable/hashtable.h
aplfw/library/container/hashtable/hashtable_findnext.c
aplfw/library/container/hashtable/hashtable_remove.c
aplfw/library/container/hashtable/hashtable_removeall.c [new file with mode: 0755]
aplfw/library/container/hashtable/hashtable_searchnode.c

index 5860aa4..14f0635 100755 (executable)
@@ -73,6 +73,7 @@ HASHTABLE_ERR         HashTable_Add(C_HASHTABLE *self, const char *pszKey, const
 HASHTABLE_ERR         HashTable_Set(C_HASHTABLE *self, const char *pszKey, const void *pData, MEMSIZE Size);                   /**< データの設定 */
 const void           *HashTable_Get(C_HASHTABLE *self, const char *pszKey);                                                                                            /**< データの参照 */
 HASHTABLE_ERR         HashTable_Remove(C_HASHTABLE *self, const char *pszKey);                                                                                 /**< データの削除 */
+void                  HashTable_RemoveAll(C_HASHTABLE *self);                                                                                                                  /**< データの全削除 */
 
 /* イテレータ */
 T_HASHTABLE_ITERATOR *HashTable_FindOpen(C_HASHTABLE *self);                                                                                                                   /**< イテレータの生成 */
index 80cf2c3..f48fea0 100755 (executable)
@@ -89,11 +89,11 @@ const void *Hashtable_FindNext(C_HASHTABLE *self, T_HASHTABLE_ITERATOR *pIterato
                pIterator->pNext->pPrev = pIterator;
                pIterator->pPrev->pNext = pIterator;
        }
-
+       
        /* データ取り出し */
        pszKey = (const char *)pNode + sizeof(T_HASHTABLE_NODE);
        pData  = (const void *)(pszKey + MemHeap_AlignSize(self->pMemHeap, strlen(pszKey)));
-
+       
        /* データ部を返す */
        *ppszKey = pszKey;
        return pData;
index 0a72c11..501ac6a 100755 (executable)
@@ -22,7 +22,7 @@ HASHTABLE_ERR HashTable_Remove(C_HASHTABLE *self, const char *pszKey)
        T_HASHTABLE_NODE                *pNodePrev;
        T_HASHTABLE_ITERATOR    *pIterator;
        int                                             iIndex;
-
+       
        /* 探索 */
        if ( (pNode = HashTable_SearchNode(self, pszKey, &pNodePrev, &iIndex)) == NULL )
        {
diff --git a/aplfw/library/container/hashtable/hashtable_removeall.c b/aplfw/library/container/hashtable/hashtable_removeall.c
new file mode 100755 (executable)
index 0000000..0563628
--- /dev/null
@@ -0,0 +1,58 @@
+/** 
+ *  Hyper Operating System  Application Framework
+ *
+ * @file  hashtable_get.c
+ * @brief %jp{ハッシュテーブルクラス}%en{hash table class}
+ *
+ * Copyright (C) 2006-2009 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include <stdio.h>
+#include <string.h>
+#include "hashtable_local.h"
+
+
+
+/** データの削除 */
+void HashTable_RemoveAll(C_HASHTABLE *self)
+{
+       T_HASHTABLE_NODE                *pNode;
+       T_HASHTABLE_NODE                *pNodeNext;
+       T_HASHTABLE_ITERATOR    *pIterator;
+       int                                             iIndex;
+       
+       for ( iIndex = 0; iIndex < self->iTableSize; iIndex++ )
+       {
+               if ( (pNode = self->ppTable[iIndex]) != NULL )
+               {
+                       do
+                       {
+                               /* 指しているイテレータがあれば外す */
+                               if ( (pIterator = pNode->pIterator) != NULL )
+                               {
+                                       do
+                                       {
+                                               pIterator->iIndex = self->iTableSize;
+                                               pIterator->pNode  = NULL;
+                                               pIterator = pIterator->pNext;
+                                       } while ( pIterator != pNode->pIterator );
+                               }
+
+                               /* ノード削除 */
+                               pNodeNext = pNode->pNext;
+                               HashTable_DeleteNode(self, pNode);
+                               self->iDataNum--;
+
+                               pNode = pNodeNext;
+                       } while ( pNode != NULL );                      
+                       
+                       self->ppTable[iIndex] = NULL;
+               }
+       }
+}
+
+
+
+/* end of file */
index 21e132c..cdc759f 100755 (executable)
@@ -47,7 +47,7 @@ T_HASHTABLE_NODE *HashTable_SearchNode(C_HASHTABLE *self, const char *pszKey, T_
        }
        
        *ppNodePrev = NULL;
-
+       
        return NULL;
 }