ListFixed.h

Go to the documentation of this file.
00001 
00019 #pragma once
00020 
00021 #pragma warning( push, 3 )
00022 #include <list>
00023 
00034 template<class T>
00035 class listFixed : public std::list< T >
00036 {
00037 #if _MSC_VER < 1300 // these problems don't affect VS7
00038     public:
00039             void sort()
00040             {
00041                     if (2 <= size())
00042                     {
00043                             const size_t _MAXN = 25;
00044                             _Myt _X(allocator), _A[_MAXN + 1];
00045                             size_t _N = 0;
00046                             while (!empty())
00047                             {
00048                                     _X.splice(_X.begin(), *this, begin());
00049                                     size_t _I;
00050                                     for (_I = 0; _I < _N && !_A[_I].empty(); ++_I)
00051                                     {
00052                                             _A[_I].merge(_X);
00053                                             _A[_I].swap(_X); 
00054                                     }
00055                                     if (_I == _MAXN)
00056                                     //  _A[_I].merge(_X); <---------- old line
00057                                             _A[_I - 1].merge(_X); // <--- bugfixed line
00058                                     else
00059                                     {
00060                                             _A[_I].swap(_X);
00061                                             if (_I == _N)
00062                                                     ++_N; 
00063                                     }
00064                             }
00065                             while (0 < _N)
00066                                     merge(_A[--_N]); 
00067                     }
00068             }
00069 
00070         void sort(_Pr3 _Pr)
00071             {
00072                     if (2 <= size())
00073                     {
00074                             const size_t _MAXN = 15;
00075                             _Myt _X(allocator), _A[_MAXN + 1];
00076                             size_t _N = 0;
00077                             while (!empty())
00078                             {
00079                                     _X.splice(_X.begin(), *this, begin());
00080                                     size_t _I;
00081                                     for (_I = 0; _I < _N && !_A[_I].empty(); ++_I)
00082                                     {
00083                                             _A[_I].merge(_X, _Pr);
00084                                             _A[_I].swap(_X); 
00085                                     }
00086                                     if (_I == _MAXN)
00087                                             //_A[_I].merge(_X, _Pr); <---------- old line
00088                                             _A[_I - 1].merge(_X, _Pr); // <----- bugfixed line
00089                                     else
00090                                     {
00091                                             _A[_I].swap(_X);
00092                                             if (_I == _N)
00093                                                     ++_N; 
00094                                     }
00095                             }
00096                             while (0 < _N)
00097                                     merge(_A[--_N], _Pr); 
00098                     }
00099             }
00100 #endif // _MSC_VER < 1300 
00101 };
00102    
00103 #pragma warning ( pop )

Generated on Tue May 21 03:34:51 2002 for Archimedes by doxygen1.2.15