1 /**************************************************************************** 2 ** 3 ** This file is part of GAP, a system for computational discrete algebra. 4 ** 5 ** Copyright of GAP belongs to its developers, whose names are too numerous 6 ** to list here. Please refer to the COPYRIGHT file for details. 7 ** 8 ** SPDX-License-Identifier: GPL-2.0-or-later 9 ** 10 ** This file declares the functions for generic lists. 11 */ 12 13 #ifndef GAP_LISTFUNC_H 14 #define GAP_LISTFUNC_H 15 16 #include "system.h" 17 18 /**************************************************************************** 19 ** 20 *F AddList(<list>,<obj>) . . . . . . . . add an object to the end of a list 21 ** 22 ** 'AddList' adds the object <obj> to the end of the list <list>, i.e., 23 ** it is equivalent to the assignment '<list>[ Length(<list>)+1 ] := <obj>'. 24 ** The list is automatically extended to make room for the new element. 25 ** 'AddList' returns nothing, it is called only for its side effect. 26 */ 27 void AddList(Obj list, Obj obj); 28 29 void AddPlist(Obj list, Obj obj); 30 31 32 /**************************************************************************** 33 ** 34 *F PositionSortedList(<list>,<obj>) . . . . find an object in a sorted list 35 *F PositionSortedDensePlist(<list>,<obj>) . find an object in a sorted list 36 ** 37 ** 'PositionSortedList' returns the position of the object <obj>, which may 38 ** be an object of any type, with respect to the sorted list <list>. 39 ** 40 ** 'PositionSortedList' returns <pos> such that '<list>[<pos>-1] < <obj>' 41 ** and '<obj> <= <list>[<pos>]'. That means if <obj> appears once in <list> 42 ** its position is returned. If <obj> appears several times in <list>, the 43 ** position of the first occurrence is returned. If <obj> is not an element 44 ** of <list>, the index where <obj> must be inserted to keep the list sorted 45 ** is returned. 46 */ 47 UInt PositionSortedList(Obj list, Obj obj); 48 49 UInt PositionSortedDensePlist(Obj list, Obj obj); 50 51 52 /**************************************************************************** 53 ** 54 *F SORT_LIST(<list>) . . . . . . . . . . . . . . . . . . . . . . sort a list 55 *F SortDensePlist(<list>) . . . . . . . . . . . . . . . . . . . sort a list 56 *F SORT_LISTComp(<list>,<func>) . . . . . . . . . . . . . . . . sort a list 57 *F SortDensePlistComp(<list>,<func>) . . . . . . . . . . . . . . sort a list 58 ** 59 *F SORT_PARA_LIST(<list>,<shadow>) . . . . . . . . . sort a list with shadow 60 *F SortParaDensePlistPara(<list>,<shadow>) . . . . . sort a list with shadow 61 *F SORT_PARA_LISTComp(<list>,<shadow>,<func>) . . . sort a list with shadow 62 *F SortParaDensePlistComp(<list>,<shadow>,<func>) . sort a list with shadow 63 ** 64 *F SortPlistByRawObj(<list>) . . . . . . . . sort a list by raw obj pointer 65 ** 'SortList' sorts the list <list> in increasing order. 66 */ 67 void SORT_LIST(Obj list); 68 69 void SortDensePlist(Obj list); 70 71 void SORT_LISTComp(Obj list, Obj func); 72 73 void SortDensePlistComp(Obj list, Obj func); 74 75 void SORT_PARA_LIST(Obj list, Obj shadow); 76 77 void SortParaDensePlist(Obj list, Obj shadow); 78 79 void SORT_PARA_LISTComp(Obj list, Obj shadow, Obj func); 80 81 void SortParaDensePlistComp(Obj list, Obj shadow, Obj func); 82 83 void SortPlistByRawObj(Obj list); 84 85 /**************************************************************************** 86 ** 87 *F RemoveDupsDensePlist(<list>) . . . . remove duplicates from a plain list 88 ** 89 ** 'RemoveDupsDensePlist' removes duplicate elements from the dense 90 ** plain list <list>. <list> must be sorted. 'RemoveDupsDensePlist' 91 ** returns 0 if <list> contains mutable elements, 1 if immutable but 92 ** not homogeneous, 2 otherwise 93 */ 94 UInt RemoveDupsDensePlist(Obj list); 95 96 97 /**************************************************************************** 98 ** 99 *F * * * * * * * * * * * * * initialize module * * * * * * * * * * * * * * * 100 */ 101 102 103 /**************************************************************************** 104 ** 105 *F InitInfoListFunc() . . . . . . . . . . . . . . . table of init functions 106 */ 107 StructInitInfo * InitInfoListFunc ( void ); 108 109 110 #endif // GAP_LISTFUNC_H 111