?? searchunsorted.h
字號(hào):
#if !defined HAVE_SEARCHUNSORTED_H__#define HAVE_SEARCHUNSORTED_H__#include "fxttypes.h"template <typename Type>ulong search_unsorted(const Type *f, ulong n, const Type v, ulong s=0)//// Return index (>=s) of first element in f[] that is == v// Return ~0 if there is no such element//// Must have n!=0{ ulong k; for (k=s; k<n; ++k) if ( f[k] == v ) return k; return ~0UL;}// -------------------------template <typename Type>ulong search_unsorted_ge(const Type *f, ulong n, const Type v, ulong s=0)//// Return index (>=s) of first element in f[] that is >= v// Return ~0 if there is no such element//// Must have n!=0{ ulong k; for (k=s; k<n; ++k) if ( f[k] >= v ) return k; return ~0UL;}// -------------------------template <typename Type>ulong search_unsorted_approx(const Type *f, ulong n, const Type v, Type da, ulong s=0)//// Return index (>=s) of first element x in f[] for which |(x-v)| <= da// Return ~0 if there is no such element//// Makes sense mostly with inexact types (float or double)//// Must have n!=0{ if ( da<0 ) da = -da; ulong k; for (k=s; k<n; ++k) { Type d; d = ( f[k] > v ? f[k]-v : v-f[k]); if ( d <= da ) return k; } return ~0UL;}// -------------------------#endif // !defined HAVE_SEARCHUNSORTED_H__
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -