00001 /* 00002 The Alphanum Algorithm is an improved sorting algorithm for strings 00003 containing numbers. Instead of sorting numbers in ASCII order like a 00004 standard sort, this algorithm sorts numbers in numeric order. 00005 00006 The Alphanum Algorithm is discussed at http://www.DaveKoelle.com 00007 00008 This implementation is Copyright (c) 2008 Dirk Jagdmann <doj@cubic.org>. 00009 It is a cleanroom implementation of the algorithm and not derived by 00010 other's works. In contrast to the versions written by Dave Koelle this 00011 source code is distributed with the libpng/zlib license. 00012 00013 This software is provided 'as-is', without any express or implied 00014 warranty. In no event will the authors be held liable for any damages 00015 arising from the use of this software. 00016 00017 Permission is granted to anyone to use this software for any purpose, 00018 including commercial applications, and to alter it and redistribute it 00019 freely, subject to the following restrictions: 00020 00021 1. The origin of this software must not be misrepresented; you 00022 must not claim that you wrote the original software. If you use 00023 this software in a product, an acknowledgment in the product 00024 documentation would be appreciated but is not required. 00025 00026 2. Altered source versions must be plainly marked as such, and 00027 must not be misrepresented as being the original software. 00028 00029 3. This notice may not be removed or altered from any source 00030 distribution. */ 00031 00032 /* $Header: /code/doj/alphanum.hpp,v 1.3 2008/01/28 23:06:47 doj Exp $ 00033 00034 slightly modified version, the main function is unaltered, but the 00035 interface definitions are changed to better suit hugins needs 00036 */ 00037 00038 #ifndef ALPHANUM__HPP 00039 #define ALPHANUM__HPP 00040 00041 #include <hugin_shared.h> 00042 #include <functional> 00043 #include <string> 00044 00045 // TODO: make comparison with hexadecimal numbers. Extend the alphanum_comp() function by traits to choose between decimal and hexadecimal. 00046 00047 namespace doj 00048 { 00049 00057 IMPEX int alphanum_comp(const std::string& l, const std::string& r); 00058 IMPEX int alphanum_comp(const char* l, const char* r); 00059 00061 00066 struct IMPEX alphanum_less : public std::binary_function<const std::string&, const std::string&, bool> 00067 { 00068 bool operator()(const std::string& left, const std::string& right) const; 00069 }; 00070 00071 } 00072 00073 #endif
1.3.9.1