The Fib multimedia system
Fib is a system for storing multimedia data (like images or films).
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
nBalanceLists.h
Go to the documentation of this file.
1 /**
2  * @file nBalanceLists
3  * file name: nBalanceLists.h
4  * @author Betti Oesterholz
5  * @date 23.08.2010
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This header specifies functions for balancing fib -objects lists.
11  * Copyright (C) @c GPL3 2010 Betti Oesterholz
12  *
13  * This program is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License (GPL) as
15  * published by the Free Software Foundation, either version 3 of the
16  * License, or any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program. If not, see <http://www.gnu.org/licenses/>.
25  *
26  *
27  * This header specifies functions for balancing fib -objects lists.
28  */
29 /*
30 History:
31 23.08.2010 Oesterholz created
32 02.10.2010 Oesterholz eliminateListTree() and eliminateListTrees() added
33 */
34 
35 #ifndef ___N_BALANCE_LISTS_H__
36 #define ___N_BALANCE_LISTS_H__
37 
38 #include "version.h"
39 
40 #include "cFibElement.h"
41 #include "cList.h"
42 
43 
44 namespace fib{
45 
46 namespace algorithms{
47 
48 namespace nTidyFibObjects{
49 
50 namespace nBalanceLists{
51 
52  /**
53  * This function will balance the given listobject.
54  * It will split the given list into more list, so that every list
55  * dosn't contain more than ulMaxUnderobjects underobjects.
56  * The created list will be underobjects of the given list.
57  * The maximal depth of the created list tree will be minimal d and the
58  * minimal depth of the created list tree will be (d - 1) .
59  *
60  * @param pListToBalance a pointer to the list to balance
61  * @param ulMaxUnderobjects the maximum number of underobjects the
62  * balanced lists should have
63  * @return a pointer to the balanced list pListToBalance
64  */
65  cList * balanceList( cList * pListToBalance,
66  unsigned long ulMaxUnderobjects );
67 
68  /**
69  * This function will balance the given listobjecttree.
70  * Every listelement which is an direct underobject of the given list
71  * or wich is an direct underobject of such list is element of the
72  * listtree.
73  * It will split the given listtree into more list, so that every list
74  * dosn't contain more than ulMaxUnderobjects underobjects.
75  * The created list will be underobjects of the given list.
76  * The maximal depth of the created list tree will be minimal d and the
77  * minimal depth of the created list tree will be (d - 1) .
78  *
79  * This function works basicly like balanceList(), if all non listelement
80  * listunderobjects of the listtree are combined in one listelement.
81  *
82  * @see balanceList()
83  * @param pListToBalance a pointer to the list to balance
84  * @param ulMaxUnderobjects the maximum number of underobjects the
85  * balanced lists should have
86  * @return a pointer to the balanced list pListToBalance
87  */
88  cList * balanceListTree( cList * pListToBalance,
89  unsigned long ulMaxUnderobjects );
90 
91 
92  /**
93  * This function balances all listelements in the given fib -object.
94  * It will split the contained lists into more list, so that every list
95  * dosn't contain more than ulMaxUnderobjects underobjects.
96  * The created list will be underobjects of the given list.
97  *
98  * @see balanceList()
99  * @see balanceListTree()
100  * @param bCombineSubLists if true the lists are combined recursive
101  * with ther direct sublists (@see balanceListTree() will be used
102  * to balance the lists), else, if false, all lists will be
103  * considerd seperatly (@see balanceList() will be used to balance
104  * the lists)
105  * @param pFibObject a pointer to the fib -object to balance
106  * @param ulMaxUnderobjects the maximum number of underobjects the
107  * balanced lists should have
108  * @return a pointer to the balanced fib -object pFibObject
109  */
111  unsigned long ulMaxUnderobjects, bool bCombineSubLists = false );
112 
113  /**
114  * This function will balance the underobjects in the given list.
115  * It will portion the given underobjects into fib -listelements, so
116  * that every created listelements contains maximal ulMaxUnderobjects
117  * underobjects. The underobjects of the given list will be in the last
118  * layer of the created listtree.
119  * The created listelements will be nested, so that each contain
120  * maximal ulMaxUnderobjects underobjects.
121  * Beware: You have to care, that the returned listobject is deleted after usage.
122  *
123  * @param liInOutUnderobjects a reference to the list with the underobjects
124  * Beware: This list will be changed. (To speed up the evaluation.)
125  * @param ulMaxUnderobjects the maximum number of underobjects the
126  * balanced lists should have
127  * @return the balanced listtree with the given underobjects liInOutUnderobjects
128  */
130  list<cFibElement*> & liInOutUnderobjects,
131  unsigned long ulMaxUnderobjects );
132 
133  /**
134  * This function builds an listobject, which is equivalent to the
135  * given listobject, but which topmost listelement has no listobjects
136  * as underobjects.
137  * For this, all underobjects of the topmost listelement, wich are
138  * listobjects, are replaced by the ther topmost underobjects, which
139  * arn't listobjects.
140  *
141  * @param pList a pointer to the listobject, wher to eleminate the
142  * direct listunderobjects
143  * @return a pointer to the listobject pList, which has no direct
144  * listunderobjects
145  */
146  cList * eliminateListTree( cList * pList );
147 
148  /**
149  * This function eleminates all listunderobjects of all listobjects
150  * in the given fib -object pFibObject.
151  * The changed fib -object will represent the same multimediaobject
152  * as the original.
153  *
154  * @see eliminateListTree()
155  * @param pFibObject a pointer to the fib -object, wher to eleminate
156  * the direct listunderobjects of the listobjects
157  * @return a pointer to the fib -object pFibObject, in which the
158  * listobjects have no direct listunderobjects
159  */
160  cFibElement * eliminateListTrees( cFibElement * pFibObject );
161 
162 
163 };//end namespace nBalanceLists
164 };//end namespace nTidyFibObjects
165 };//end namespace algorithms
166 };//end namespace fib
167 
168 
169 #endif //___N_BALANCE_LISTS_H__