XFuPriorityList.h Source File

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# XFuPriorityList.h

Go to the documentation of this file.

    00001 /*! \file
    00002  * X-Forge Util <br>
    00003  * Copyright 2000-2003 Fathammer Ltd
    00004  *
    00005  * \brief Priority Linked list template
    00006  *
    00007  * $Id: XFuPriorityList.h,v 1.8 2003/08/12 13:33:52 lars Exp $
    00008  * $Date: 2003/08/12 13:33:52 $
    00009  * $Revision: 1.8 $
    00010  */
    00011
    00012 #ifndef XFUPRIORITYLIST_H_INCLUDED
    00013 #define XFUPRIORITYLIST_H_INCLUDED
    00014
    00015 #include <xfcore/XFcLinkedList.h>
    00016 #include <xfutil/XFuPriorityHelp.h>
    00017
    00018
    00019 template<class T>
    00020 class XFuPriorityList : public XFcLinkedList<T>
    00021 {
    00022 private:
    00023     XFuPriorityHelp *mPriorityHelp;
    00024
    00025 public:
    00026
    00027     //! Constructor.
    00028     XFuPriorityList(XFuPriorityHelp *aPriorityHelp);
    00029
    00030     //! Constructor.
    00031     XFuPriorityList();
    00032
    00033     //! Virtual destructor.
    00034     virtual ~XFuPriorityList();
    00035
    00036     //! Sets priority helper.
    00037     void setPriorityHelp(XFuPriorityHelp *aPriorityHelp);
    00038
    00039     //! Add first by priority.
    00040     INT addPriorityFirst(T aNewData);
    00041
    00042     //! Add last by priority.
    00043     INT addPriorityLast(T aNewData);
    00044
    00045     //! Decreases all priorities.
    00046     void decreasePriorities();
    00047
    00048     //! Increases priorities.
    00049     void increasePriorities();
    00050
    00051     //! Removes first.
    00052     INT removeFirst();
    00053
    00054     //! Remove last.
    00055     INT removeLast();
    00056 };
    00057
    00058
    00059 template<class T>
    00060 XFuPriorityList<T>::XFuPriorityList()
    00061 {
    00062 }
    00063
    00064
    00065 template<class T>
    00066 XFuPriorityList<T>::XFuPriorityList(
    00067     XFuPriorityHelp *aPriorityHelp) : mPriorityHelp(aPriorityHelp)
    00068 {
    00069 }
    00070
    00071
    00072 template<class T>
    00073 XFuPriorityList<T>::~XFuPriorityList()
    00074 {
    00075 }
    00076
    00077
    00078 template<class T>
    00079 void XFuPriorityList<T>::setPriorityHelp(XFuPriorityHelp *aPriorityHelp)
    00080 {
    00081     mPriorityHelp = aPriorityHelp;
    00082 }
    00083
    00084
    00085 template <class T>
    00086 INT XFuPriorityList<T>::addPriorityFirst(T aNewData)
    00087 {
    00088     INT i = 0;
    00089
    00090     XFcLinkedList<T>::forwardIterator it;
    00091     T temp;
    00092
    00093     for (it = forwardBegin(); it != forwardEnd(); it++)
    00094     {
    00095         temp = it.getValue();
    00096         // +1 is higher and -1 lower 0 is same
    00097         if (mPriorityHelp->priorityCheck(temp, aNewData) > 0)
    00098             break;
    00099         i ++;
    00100     }
    00101
    00102     return add(i, aNewData);
    00103 }
    00104
    00105
    00106 template <class T>
    00107 INT XFuPriorityList<T>::addPriorityLast(T aNewData)
    00108 {
    00109
    00110     INT i = 0;
    00111
    00112     XFcLinkedList<T>::forwardIterator it;
    00113     T temp;
    00114
    00115     for (it = forwardBegin(); it != forwardEnd(); it++)
    00116     {
    00117         temp = it.getData();
    00118         // +1 is higher and -1 lower 0 is same
    00119         if (mPriorityHelp->priorityCheck(temp, aNewData) < 0)
    00120             break;
    00121         i ++;
    00122     }
    00123
    00124     return add(i, aNewData);
    00125 }
    00126
    00127
    00128 template<class T>
    00129 void XFuPriorityList<T>::decreasePriorities()
    00130 {
    00131     XFcLinkedList<T>::forwardIterator it;
    00132     T temp;
    00133
    00134     for (it = forwardBegin(); it != forwardEnd(); it++)
    00135     {
    00136         temp = it.getData();
    00137         mPriorityHelp->decrease(temp);
    00138     }
    00139 }
    00140
    00141
    00142 template<class T>
    00143 void XFuPriorityList<T>::increasePriorities()
    00144 {
    00145     XFcLinkedList<T>::forwardIterator it;
    00146     T temp;
    00147
    00148     for (it = forwardBegin(); it != forwardEnd(); it++)
    00149     {
    00150         temp = it.getValue();
    00151         mPriorityHelp->increase(temp);
    00152     }
    00153 }
    00154
    00155
    00156 template<class T>
    00157 INT XFuPriorityList<T>::removeFirst()
    00158 {
    00159     return removeIndex(0);
    00160 }
    00161
    00162
    00163 template<class T>
    00164 INT XFuPriorityList<T>::removeLast()
    00165 {
    00166     return removeIndex(size());
    00167 }
    00168
    00169
    00170 #endif // !XFUPRIORITYLIST_H_INCLUDED
    00171

|  | X-Forge Documentation Confidential Copyright © 2002-2003 Fathammer |  | Documentation generated with doxygen by Dimitri van Heesch