diff --git a/Common/ListUtils.cpp b/Common/ListUtils.cpp index 2cbb0eb33ed1871420b5a99879028aa44774904a..c90dbcec49b802816a21c557f8e9ef32294af82c 100644 --- a/Common/ListUtils.cpp +++ b/Common/ListUtils.cpp @@ -96,22 +96,6 @@ void List_Write(List_T * liste, int index, void *data) } } -void List_Put(List_T * liste, int index, void *data) -{ - if(index < 0) - Msg::Error("Wrong list index (put)"); - else { - if(index >= liste->n) { - liste->n = index + 1; - List_Realloc(liste, liste->n); - List_Write(liste, index, data); - } - else { - List_Write(liste, index, data); - } - } -} - void List_Pop(List_T * liste) { if(liste->n > 0) @@ -140,15 +124,6 @@ void *List_Pointer_Fast(List_T * liste, int index) return (&liste->array[index * liste->size]); } -void *List_Pointer_Test(List_T * liste, int index) -{ - if(!liste || (index < 0) || (index >= liste->n)) - return NULL; - - liste->isorder = 0; - return (&liste->array[index * liste->size]); -} - void List_Sort(List_T * liste, int (*fcmp) (const void *a, const void *b)) { qsort(liste->array, liste->n, liste->size, fcmp); @@ -186,20 +161,6 @@ int List_Search(List_T * liste, void *data, return (1); } -int List_ISearch(List_T * liste, void *data, - int (*fcmp) (const void *a, const void *b)) -{ - void *ptr; - - if(liste->isorder != 1) - List_Sort(liste, fcmp); - liste->isorder = 1; - ptr = (void *)bsearch(data, liste->array, liste->n, liste->size, fcmp); - if(ptr == NULL) - return (-1); - return (((long)ptr - (long)liste->array) / liste->size); -} - int List_ISearchSeq(List_T * liste, void *data, int (*fcmp) (const void *a, const void *b)) { @@ -276,16 +237,6 @@ void List_Copy(List_T * a, List_T * b) } } -void List_Merge(List_T * a, List_T * b) -{ - int i; - - if(!a || !b) return; - for(i = 0; i < List_Nbr(a); i++) { - List_Add(b, List_Pointer_Fast(a, i)); - } -} - void List_Remove(List_T *a, int i) { memcpy(&a->array[i * a->size], &a->array[(i + 1) * a->size], @@ -306,6 +257,19 @@ void List_Insert_In_List(List_T *a, int i, List_T *b) memcpy(List_Pointer_Fast(b, i + j), List_Pointer_Fast(a, j), b->size); } +List_T *ListOfDouble2ListOfInt(List_T *dList) +{ + int n = List_Nbr(dList); + List_T *iList = List_Create(n, n, sizeof(int)); + for(int i = 0; i < n; i++){ + double d; + List_Read(dList, i, &d); + int j = (int)d; + List_Add(iList, &j); + } + return iList; +} + // Comparison functions int fcmp_int(const void *a, const void *b) @@ -331,16 +295,3 @@ int fcmp_double(const void *a, const void *b) return 0; } -List_T *ListOfDouble2ListOfInt(List_T *dList) -{ - int n = List_Nbr(dList); - List_T *iList = List_Create(n, n, sizeof(int)); - for(int i = 0; i < n; i++){ - double d; - List_Read(dList, i, &d); - int j = (int)d; - List_Add(iList, &j); - } - return iList; -} - diff --git a/Common/ListUtils.h b/Common/ListUtils.h index 4e659d8df1db8e4b1e2b6780157ecf44fa8af9c2..b2005733f30cc1fccc5975831ff15d867298b077 100644 --- a/Common/ListUtils.h +++ b/Common/ListUtils.h @@ -6,11 +6,6 @@ #ifndef _LIST_UTILS_H_ #define _LIST_UTILS_H_ -#include <stdio.h> - -#define LIST_FORMAT_ASCII 0 -#define LIST_FORMAT_BINARY 1 - class List_T { public: int nmax; @@ -33,11 +28,9 @@ void List_Pop(List_T *liste); void *List_Pointer(List_T *liste, int index); void *List_Pointer_NoChange(List_T *liste, int index); void *List_Pointer_Fast(List_T *liste, int index); -void *List_Pointer_Test(List_T *liste, int index); void List_Sort(List_T *liste, int (*fcmp)(const void *a, const void *b)); void List_Unique(List_T *liste, int (*fcmp)(const void *a, const void *b)); int List_Search(List_T *liste, void *data, int (*fcmp)(const void *a, const void *b)); -int List_ISearch(List_T *liste, void *data, int (*fcmp)(const void *a, const void *b)); int List_ISearchSeq(List_T *liste, void * data, int (*fcmp)(const void *a, const void *b)); void *List_PQuery(List_T *liste, void *data, int (*fcmp)(const void *a, const void *b)); int List_PSuppress(List_T *liste, int index); @@ -45,15 +38,12 @@ void List_Invert(List_T *a, List_T *b); void List_Reset(List_T *liste); void List_Action(List_T *liste, void (*action)(void *data, void *dummy)); void List_Copy(List_T *a , List_T *b); -void List_Merge(List_T *a , List_T *b); void List_Remove (List_T *a, int i); void List_Insert_In_List (List_T *a, int i, List_T *b); +List_T *ListOfDouble2ListOfInt(List_T *dList); int fcmp_int(const void *a, const void *b); int fcmp_absint(const void *a, const void *b); int fcmp_double(const void *a, const void *b); -List_T *ListOfDouble2ListOfInt(List_T *dList); - #endif - diff --git a/Common/TreeUtils.cpp b/Common/TreeUtils.cpp index 312d32feef6d098ec795aa69938b066268af01d0..61fa6b44806d357477188779a30e8300cf14ceaf 100644 --- a/Common/TreeUtils.cpp +++ b/Common/TreeUtils.cpp @@ -93,6 +93,12 @@ int Tree_Size(Tree_T * tree) return tree->size; } +void Tree_Action(Tree_T *tree, void (*action) (void *data, void *dummy)) +{ + if(!tree) return; + avl_foreach(tree->root, action, AVL_FORWARD); +} + static List_T *pListTransfer; void TransferList(void *a, void *b) diff --git a/Common/TreeUtils.h b/Common/TreeUtils.h index b10ae5304ddfc0487a56a3743cfb4e523b460ce1..b3d83eee77c9dbe8faae8de86b04f13a2f0ae89d 100644 --- a/Common/TreeUtils.h +++ b/Common/TreeUtils.h @@ -24,15 +24,7 @@ int Tree_Query(Tree_T *Tree, void *data); void *Tree_PQuery(Tree_T *Tree, void *data); int Tree_Suppress(Tree_T *Tree, void *data); int Tree_Size(Tree_T *tree) ; - -inline void Tree_Action(Tree_T *tree, void (*action) (void *data, void *dummy)) -{ - if(!tree) return; - - avl_foreach(tree->root, action, AVL_FORWARD); -} - +void Tree_Action(Tree_T *tree, void (*action) (void *data, void *dummy)); List_T *Tree2List(Tree_T *pTree); #endif - diff --git a/Common/avl.cpp b/Common/avl.cpp index d28c639d11d9854da86559ccc2f3f8938af23ac8..368ab6e009eb10c3150fa3bfd33117e92bc8a329 100644 --- a/Common/avl.cpp +++ b/Common/avl.cpp @@ -23,7 +23,7 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -// Modified for Gmsh (C++, 64 bits, ...) +// Modified for Gmsh (C++ and 64 bit compatibility) #include <stdio.h>