00001 /* Part of the culibs project, <http://www.eideticdew.org/culibs/>. 00002 * Copyright (C) 2005--2007 Petter Urkedal <urkedal@nbi.dk> 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef CU_ALGO_H 00019 #define CU_ALGO_H 00020 00021 #include <cu/fwd.h> 00022 00023 CU_BEGIN_DECLARATIONS 00024 /** \defgroup cu_algo_h cu/algo.h: Supportive definitions for various algorithms 00025 ** @{ \ingroup cu_util_mod */ 00026 00027 /** Enumeration of partial order relations. */ 00028 typedef enum { 00029 cu_order_none = 0, /*!< no ordering relation applies */ 00030 cu_order_lt = 13, /*!< less-than ordering */ 00031 cu_order_gt = 14, /*!< greater-than ordering */ 00032 cu_order_eq = 3, /*!< equal-to ordering */ 00033 } cu_order_t; 00034 00035 /** The opposite ordering of \a order. */ 00036 CU_SINLINE cu_order_t 00037 cu_order_rev(cu_order_t order) 00038 { return (cu_order_t)(order ^ (order >> 2)); } 00039 00040 CU_SINLINE void 00041 cu_ptr_swap(cu_ptr_ptr_t p0, cu_ptr_ptr_t p1) 00042 { 00043 void *pS = *(void **)p0; 00044 *(void **)p0 = *(void **)p1; 00045 *(void **)p1 = pS; 00046 } 00047 00048 CU_SINLINE void 00049 cu_ptr_rotl(cu_ptr_ptr_t p0, cu_ptr_ptr_t p1, cu_ptr_ptr_t p2) 00050 { 00051 void *pS = *(void **)p0; 00052 *(void **)p0 = *(void **)p1; 00053 *(void **)p1 = *(void **)p2; 00054 *(void **)p2 = pS; 00055 } 00056 00057 /** @} */ 00058 CU_END_DECLARATIONS 00059 00060 #endif