Vegastrike 0.5.1 rc1
1.0
Original sources for Vegastrike Evolved
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
opcodealgorithms.h
Go to the documentation of this file.
1
/*
2
Crystal Space General Algorithms
3
Copyright (C)2005 by Marten Svanfeldt
4
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
9
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
14
15
You should have received a copy of the GNU Library General Public
16
License along with this library; if not, write to the Free
17
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
*/
19
20
#ifndef __CSUTIL_ALGORITHMS_H__
21
#define __CSUTIL_ALGORITHMS_H__
22
27
namespace
CS
28
{
29
33
template
<
class
T>
34
CS_FORCEINLINE_TEMPLATEMETHOD
void
Swap
(T&
a
, T&
b
)
35
{
36
T tmp =
a
;
37
a =
b
;
38
b = tmp;
39
}
40
51
template
<
class
T,
class
Fn>
52
CS_FORCEINLINE_TEMPLATEMETHOD
Fn&
ForEach
(T it, Fn& Func)
53
{
54
while
(it.HasNext ())
55
{
56
Func (it.Next ());
57
}
58
return
Func;
59
}
60
65
template
<
class
T,
class
Fn>
66
CS_FORCEINLINE_TEMPLATEMETHOD
Fn&
ForEach
(T*
start
, T* end, Fn& Func)
67
{
68
while
(start != end)
69
{
70
Func (*start);
71
start++;
72
}
73
return
Func;
74
}
75
80
template
<
class
T,
class
Fn,
class
P>
81
CS_FORCEINLINE_TEMPLATEMETHOD
Fn&
ForEach
(T it, Fn& Func, P& p)
82
{
83
while
(it.HasNext ())
84
{
85
Func (it.Next (), p);
86
}
87
return
Func;
88
}
89
90
91
}
92
93
#endif // __CSUTIL_ALGORITHMS_H__
src
cmd
collide2
opcodealgorithms.h
Generated on Fri May 29 2015 23:07:13 for Vegastrike 0.5.1 rc1 by
1.8.4