nskipnode.hpp

Go to the documentation of this file.
00001 // LICENSE: (Please see the file COPYING for details)
00002 //
00003 // NUS - Nemesis Utilities System: A C++ application development framework 
00004 // Copyright (C) 2006, 2008 Otavio Rodolfo Piske
00005 //
00006 //  This file is part of NUS
00007 //
00008 //  This library is free software; you can redistribute it and/or
00009 //  modify it under the terms of the GNU Lesser General Public
00010 //  License as published by the Free Software Foundation version 2.1
00011 //  of the License.
00012 //
00013 //  This library is distributed in the hope that it will be useful,
00014 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 //  Lesser General Public License for more details.
00017 //
00018 //  You should have received a copy of the GNU Lesser General Public
00019 //  License along with this library; if not, write to the Free Software
00020 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00021 //
00022 #ifndef NSKIPNODE_HPP
00023 #define NSKIPNODE_HPP
00024 
00036 template <typename T>
00037 class NSkipNode {
00038       public:
00042             T data;
00046             nint32 height;
00050             NSkipNode<T> **next;
00051             
00055             NSkipNode(void);
00056             
00061             NSkipNode(nint32 height);
00062             
00068             NSkipNode(nint32 height, const T &val);
00069             
00073             ~NSkipNode(void);
00074 
00075       private:
00079             void nzero(void);
00080             
00081             NSkipNode(const NSkipNode &);
00082             NSkipNode &operator=(const NSkipNode &);
00083 };
00084 
00085 template <typename T>
00086 NSkipNode<T>::NSkipNode(void)
00087       : data(),
00088       height(0),
00089       next(NULL)
00090 {
00091 
00092 }
00093 
00094 
00095 template <typename T>
00096 NSkipNode<T>::NSkipNode(nint32 h)
00097       : data(),
00098       height(h),
00099       next(NULL)
00100 {
00101       next = new NSkipNode*[height];
00102       nzero();
00103 }
00104 
00105 
00106 template <typename T>
00107 NSkipNode<T>::NSkipNode(nint32 h, const T &val)
00108       : data(),
00109       height(h),
00110       next(NULL)
00111 {
00112       next = new NSkipNode*[height];
00113       nzero();
00114       data = val;
00115 }
00116 
00117 template <typename T>
00118 NSkipNode<T>::~NSkipNode(void) {
00119       delete[] next;
00120 }
00121 
00122 
00123 template <typename T>
00124 void NSkipNode<T>::nzero(void) {
00125       for (int i = 0; i < height; i++) {
00126             next[i] = NULL;
00127       }
00128 }
00129 #endif // NSKIPNODE_HPP

Generated on Wed Mar 5 23:10:35 2008 for NemesisUtilitiesSystem by  doxygen 1.5.4