1 /* 2 * 3 * Copyright (c) 1994 4 * Hewlett-Packard Company 5 * 6 * Permission to use, copy, modify, distribute and sell this software 7 * and its documentation for any purpose is hereby granted without fee, 8 * provided that the above copyright notice appear in all copies and 9 * that both that copyright notice and this permission notice appear 10 * in supporting documentation. Hewlett-Packard Company makes no 11 * representations about the suitability of this software for any 12 * purpose. It is provided "as is" without express or implied warranty. 13 * 14 * 15 * Copyright (c) 1996 16 * Silicon Graphics Computer Systems, Inc. 17 * 18 * Permission to use, copy, modify, distribute and sell this software 19 * and its documentation for any purpose is hereby granted without fee, 20 * provided that the above copyright notice appear in all copies and 21 * that both that copyright notice and this permission notice appear 22 * in supporting documentation. Silicon Graphics makes no 23 * representations about the suitability of this software for any 24 * purpose. It is provided "as is" without express or implied warranty. 25 */ 26 27 /* 28 Copyright (c) 2007 Lao wen bo 29 30 This software is provided 'as-is', without any express or implied 31 warranty. In no event will the authors be held liable for any damages 32 arising from the use of this software. 33 34 Permission is granted to anyone to use this software for any purpose, 35 including commercial applications, and to alter it and redistribute it 36 freely, subject to the following restrictions: 37 38 1. The origin of this software must not be misrepresented; you must not 39 claim that you wrote the original software. If you use this software 40 in a product, an acknowledgment in the product documentation would be 41 appreciated but is not required. 42 43 2. Altered source versions must be plainly marked as such, and must not be 44 misrepresented as being the original software. 45 46 3. This notice may not be removed or altered from any source 47 distribution. 48 49 Lao wen bo 50 viewpl(at)gmail.com 51 */ 52 53 /* 54 NOTE: This is an internal header file, You should not attempt to use it directly. 55 */ 56 57 #ifndef _C_FUNCTION_H 58 #define _C_FUNCTION_H 59 60 #include "c_iterator.h" 61 62 #define c_unary_function _c_unary_function 63 #define c_binary_function _c_binary_function 64 #define c_unary_predicate _c_unary_predicate 65 #define c_binary_predicate _c_binary_predicate 66 67 #define c_unary_negate _c_unary_negate 68 #define c_binary_negate _c_binary_negate 69 70 #define c_identity _c_identity 71 #define c_select1st _c_select1st 72 #define c_select1stptr _c_select1stptr 73 74 #define c_unary_adapt _c_unary_adapt 75 #define c_binary_adapt _c_binary_adapt 76 77 typedef value_type (*UNARY_FUNCTION)(value_type); 78 typedef value_type (*BINARY_FUNCTION)(value_type, value_type); 79 typedef c_bool (*UNARY_PREDICATE)(value_type); 80 typedef c_bool (*BINARY_PREDICATE)(value_type, value_type); 81 typedef c_bool (*PREDICATE)(value_type); 82 83 84 typedef struct c_unary_function c_unary_function; 85 typedef struct c_binary_function c_binary_function; 86 87 struct c_unary_function 88 { 89 value_type (*O)(c_unary_function * thiz, value_type val); 90 void * _l; 91 }; 92 93 struct c_binary_fuction 94 { 95 value_type (*O)(c_binary_function * thiz, value_type val1, value_type val2); 96 void * _l; 97 }; 98 99 typedef struct c_unary_predicate c_unary_predicate; 100 typedef struct c_binary_predicate c_binary_predicate; 101 102 struct c_unary_predicate 103 { 104 c_bool (*O)(c_unary_predicate * thiz, value_type val); 105 void * _l; 106 }; 107 108 struct c_binary_predicate 109 { 110 c_bool (*O)(c_binary_predicate * thiz, value_type val1, value_type val2); 111 void * _l; 112 }; 113 114 115 c_unary_predicate c_unary_negate(UNARY_PREDICATE unary_pred); 116 c_binary_predicate c_binary_negate(BINARY_PREDICATE binary_pred); 117 118 c_unary_function c_identity(); 119 c_unary_function c_select1st(); 120 c_unary_function c_select1stptr(); 121 122 c_unary_predicate c_unary_adapt(UNARY_PREDICATE unary_pred); 123 c_binary_predicate c_binary_adapt(BINARY_PREDICATE binary_pred); 124 125 #endif /* _C_FUNCTION_H */ 126 127