PixelLightAPI  .
Functions.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: Functions.h                                    *
00003  *      Different useful container functions
00004  *
00005  *  Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/)
00006  *
00007  *  This file is part of PixelLight.
00008  *
00009  *  PixelLight is free software: you can redistribute it and/or modify
00010  *  it under the terms of the GNU Lesser General Public License as published by
00011  *  the Free Software Foundation, either version 3 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  PixelLight is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017  *  GNU Lesser General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU Lesser General Public License
00020  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00021 \*********************************************************/
00022 
00023 
00024 #ifndef __PLCORE_CONTAINER_FUNCTIONS_H__
00025 #define __PLCORE_CONTAINER_FUNCTIONS_H__
00026 #pragma once
00027 
00028 
00029 //[-------------------------------------------------------]
00030 //[ Includes                                              ]
00031 //[-------------------------------------------------------]
00032 #include "PLCore/PLCore.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Namespace                                             ]
00037 //[-------------------------------------------------------]
00038 namespace PLCore {
00039 
00040 
00041 //[-------------------------------------------------------]
00042 //[ Forward declarations                                  ]
00043 //[-------------------------------------------------------]
00044 class String;
00045 
00046 
00047 //[-------------------------------------------------------]
00048 //[ Classes                                               ]
00049 //[-------------------------------------------------------]
00050 /**
00051 *  @brief
00052 *    Different standard hash functions
00053 */
00054 class HashFunction {
00055 
00056 
00057     //[-------------------------------------------------------]
00058     //[ Public static functions                               ]
00059     //[-------------------------------------------------------]
00060     public:
00061         static PLCORE_API uint32 Hash(const int32 &nKey);
00062         static PLCORE_API uint32 Hash(const uint32 &nKey);
00063         static PLCORE_API uint32 Hash(const int64 &nKey);
00064         static PLCORE_API uint32 Hash(const uint64 &nKey);
00065         static PLCORE_API uint32 Hash(const char *pszKey);
00066         static PLCORE_API uint32 Hash(const String &sKey);
00067 
00068 
00069 };
00070 
00071 /**
00072 *  @brief
00073 *    Standard compare function
00074 */
00075 class CompareFunction {
00076 
00077 
00078     //[-------------------------------------------------------]
00079     //[ Public static functions                               ]
00080     //[-------------------------------------------------------]
00081     public:
00082         // int32
00083         static PLCORE_API bool AreEqual(const int32 &nKey1, const int32 &nKey2);
00084         static PLCORE_API bool IsGreater(const int32 &nKey1, const int32 &nKey2);
00085 
00086         // uint32
00087         static PLCORE_API bool AreEqual(const uint32 &nKey1, const uint32 &nKey2);
00088         static PLCORE_API bool IsGreater(const uint32 &nKey1, const uint32 &nKey2);
00089 
00090         // int64
00091         static PLCORE_API bool AreEqual(const int64 &nKey1, const int64 &nKey2);
00092         static PLCORE_API bool IsGreater(const int64 &nKey1, const int64 &nKey2);
00093 
00094         // uint64
00095         static PLCORE_API bool AreEqual(const uint64 &nKey1, const uint64 &nKey2);
00096         static PLCORE_API bool IsGreater(const uint64 &nKey1, const uint64 &nKey2);
00097 
00098         // float
00099         static PLCORE_API bool AreEqual(const float &fKey1, const float &fKey2);
00100         static PLCORE_API bool IsGreater(const float &fKey1, const float &fKey2);
00101 
00102         // const char *
00103         static PLCORE_API bool AreEqual(const char *pszKey1, const char *pszKey2);
00104         static PLCORE_API bool IsGreater(const char *pszKey1, const char *pszKey2);
00105 
00106         // String
00107         static PLCORE_API bool AreEqual(const String &sKey1, const String &sKey2);
00108         static PLCORE_API bool IsGreater(const String &sKey1, const String &sKey2);
00109 
00110 
00111 };
00112 
00113 /**
00114 *  @brief
00115 *    Standard grow functions
00116 *
00117 *  @remarks
00118 *    The default grow function makes sure that there are at least 10% slots, if not, a new
00119 *    size basing on prime numbers is returned.
00120 */
00121 class GrowFunction {
00122 
00123 
00124     //[-------------------------------------------------------]
00125     //[ Public static functions                               ]
00126     //[-------------------------------------------------------]
00127     public:
00128         /**
00129         *  @brief
00130         *    Returns a new size
00131         *
00132         *  @param[in] nCurrentSize
00133         *    Current size
00134         *  @param[in] nFreeSlots
00135         *    Number of free slots
00136         *
00137         *  @return
00138         *    New size, if <= current size then no grow is required
00139         */
00140         static PLCORE_API uint32 GetNewSize(uint32 nCurrentSize, uint32 nFreeSlots);
00141 
00142 
00143 };
00144 
00145 
00146 //[-------------------------------------------------------]
00147 //[ Namespace                                             ]
00148 //[-------------------------------------------------------]
00149 } // PLCore
00150 
00151 
00152 #endif // __PLCORE_CONTAINER_FUNCTIONS_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:08:55
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported