[cig-commits] r5021 - in long/3D/Gale/trunk/src/StGermain: . Base/Container/src

walter at geodynamics.org walter at geodynamics.org
Sat Oct 14 11:31:04 PDT 2006


Author: walter
Date: 2006-10-14 11:31:03 -0700 (Sat, 14 Oct 2006)
New Revision: 5021

Modified:
   long/3D/Gale/trunk/src/StGermain/
   long/3D/Gale/trunk/src/StGermain/Base/Container/src/UIntMap.c
   long/3D/Gale/trunk/src/StGermain/Base/Container/src/UIntMap.h
Log:
 r3048 at earth:  boo | 2006-10-14 11:08:04 -0700
  r3036 at earth (orig r3856):  LukeHodkinson | 2006-10-14 11:04:38 -0700
  Added routines to clear the set and extract the
  key/value pairs.
  
 



Property changes on: long/3D/Gale/trunk/src/StGermain
___________________________________________________________________
Name: svk:merge
   - 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:3047
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3855
   + 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:3048
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3856

Modified: long/3D/Gale/trunk/src/StGermain/Base/Container/src/UIntMap.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/src/UIntMap.c	2006-10-14 18:31:01 UTC (rev 5020)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/src/UIntMap.c	2006-10-14 18:31:03 UTC (rev 5021)
@@ -43,9 +43,17 @@
 #include "UIntMap.h"
 
 
+typedef struct {
+	unsigned	curItem;
+	unsigned*	keys;
+	unsigned*	vals;
+} UIntMap_ParseStruct;
+
+
 /* Textual name of this class */
 const Type UIntMap_Type = "UIntMap";
 
+
 /*----------------------------------------------------------------------------------------------------------------------------------
 ** Constructors
 */
@@ -154,6 +162,16 @@
 	self->size = self->btree->nodeCount;
 }
 
+void UIntMap_Clear( void* map ) {
+	UIntMap*	self = (UIntMap*)map;
+
+	assert( self );
+
+	FreeObject( self->btree );
+	self->btree = BTree_New( UIntMap_DataCompare, UIntMap_DataCopy, UIntMap_DataDelete, NULL, 
+				  BTREE_NO_DUPLICATES );
+}
+
 Bool UIntMap_HasKey( void* map, unsigned key ) {
 	UIntMap*	self = (UIntMap*)map;
 
@@ -174,6 +192,22 @@
 	return ((unsigned*)node->data)[1];
 }
 
+void UIntMap_GetItems( void* map, unsigned* nItems, unsigned** keys, unsigned** values ) {
+	UIntMap*		self = (UIntMap*)map;
+	UIntMap_ParseStruct	parseStruct;
+
+	assert( self );
+
+	parseStruct.curItem = 0;
+	parseStruct.keys = Memory_Alloc_Array_Unnamed( unsigned, self->size );
+	parseStruct.vals = Memory_Alloc_Array_Unnamed( unsigned, self->size );
+	BTree_ParseTree( self->btree, UIntMap_ParseNode, &parseStruct );
+
+	*nItems = self->size;
+	*keys = parseStruct.keys;
+	*values = parseStruct.vals;
+}
+
 /*----------------------------------------------------------------------------------------------------------------------------------
 ** Private Functions
 */
@@ -196,3 +230,13 @@
 void UIntMap_DataDelete( void* data ) {
 	Memory_Free( data );
 }
+
+void UIntMap_ParseNode( void* data, void* _parseStruct ) {
+	UIntMap_ParseStruct*	parseStruct = (UIntMap_ParseStruct*)_parseStruct;
+
+	assert( data );
+	assert( parseStruct );
+
+	parseStruct->keys[parseStruct->curItem] = ((unsigned*)data)[0];
+	parseStruct->vals[parseStruct->curItem++] = ((unsigned*)data)[1];
+}

Modified: long/3D/Gale/trunk/src/StGermain/Base/Container/src/UIntMap.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/src/UIntMap.h	2006-10-14 18:31:01 UTC (rev 5020)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/src/UIntMap.h	2006-10-14 18:31:03 UTC (rev 5021)
@@ -91,8 +91,11 @@
 	*/
 
 	void UIntMap_Insert( void* map, unsigned key, unsigned val );
+	void UIntMap_Clear( void* map );
+
 	Bool UIntMap_HasKey( void* map, unsigned key );
 	unsigned UIntMap_Map( void* map, unsigned key );
+	void UIntMap_GetItems( void* map, unsigned* nItems, unsigned** keys, unsigned** values );
 
 	/*--------------------------------------------------------------------------------------------------------------------------
 	** Private Member functions
@@ -101,5 +104,6 @@
 	int UIntMap_DataCompare( void* left, void* right );
 	void UIntMap_DataCopy( void** dstData, void* data, SizeT size );
 	void UIntMap_DataDelete( void* data );
+	void UIntMap_ParseNode( void* data, void* _parseStruct );
 
 #endif /* __Base_Container_UIntMap_h__ */



More information about the cig-commits mailing list