Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
blaze
util
Algorithm.h
Go to the documentation of this file.
1
//=================================================================================================
20
//=================================================================================================
21
22
#ifndef _BLAZE_UTIL_ALGORITHM_H_
23
#define _BLAZE_UTIL_ALGORITHM_H_
24
25
26
//*************************************************************************************************
27
// Includes
28
//*************************************************************************************************
29
30
#include <
blaze/util/constraints/DerivedFrom.h
>
31
#include <
blaze/util/Types.h
>
32
33
34
namespace
blaze {
35
36
//=================================================================================================
37
//
38
// POLYMORPHIC COUNT
39
//
40
//=================================================================================================
41
42
//*************************************************************************************************
53
template
<
typename
D
// Dynamic type of the objects
54
,
typename
S >
// Static type of the objects
55
inline
size_t
polymorphicCount
( S *
const
* first, S *
const
* last )
56
{
57
BLAZE_CONSTRAINT_MUST_BE_STRICTLY_DERIVED_FROM
( D, S );
58
59
size_t
count( 0 );
60
for
( S *
const
* it=first; it!=last; ++it )
61
if
( dynamic_cast<D*>( *it ) ) ++count;
62
return
count;
63
}
64
//*************************************************************************************************
65
66
67
68
69
//=================================================================================================
70
//
71
// POLYMORPHIC FIND
72
//
73
//=================================================================================================
74
75
//*************************************************************************************************
86
template
<
typename
D
// Dynamic type of the objects
87
,
typename
S >
// Static type of the objects
88
inline
S *
const
*
polymorphicFind
( S *
const
* first, S *
const
* last )
89
{
90
BLAZE_CONSTRAINT_MUST_BE_STRICTLY_DERIVED_FROM
( D, S );
91
92
while
( first != last && !dynamic_cast<D*>( *first ) ) ++first;
93
return
first;
94
}
95
//*************************************************************************************************
96
97
}
// namespace blaze
98
99
#endif
Generated on Sun Jan 20 2013 08:14:38 by
1.8.3