mirror of
https://github.com/boostorg/array.git
synced 2025-07-12 12:16:32 +02:00
initial checkin of Nico's array library
[SVN r7678]
This commit is contained in:
54
array2.cpp.html
Normal file
54
array2.cpp.html
Normal file
@ -0,0 +1,54 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>array2.cpp</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
|
||||
|
||||
<TABLE HEIGHT=40 WIDTH="100%">
|
||||
<TR> <TD ALIGN=LEFT WIDTH="100%" BGCOLOR="#DDDDDD">
|
||||
<FONT face="Arial,Helvetica" size=+2><B>
|
||||
array2.cpp
|
||||
</B></FONT>
|
||||
</TD></TR></TABLE><BR>
|
||||
|
||||
<BR><BR>
|
||||
<TT>
|
||||
<SPAN class="Source">
|
||||
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >* example for using class array<></FONT></I><BR>
|
||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*/</FONT></I><BR>
|
||||
#include <algorithm><BR>
|
||||
#include <functional><BR>
|
||||
#include <<A href="./array.hpp.html">boost/array.hpp</A>><BR>
|
||||
#include "<A href="print.hpp.html">print.hpp</A>"<BR>
|
||||
using namespace std;<BR>
|
||||
using namespace boost;<BR>
|
||||
<BR>
|
||||
int main()<BR>
|
||||
{<BR>
|
||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// create and initialize array</FONT></I><BR>
|
||||
array<int,10> a = { { 1, 2, 3, 4, 5 } };<BR>
|
||||
<BR>
|
||||
PRINT_ELEMENTS(a);<BR>
|
||||
<BR>
|
||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// modify elements directly</FONT></I><BR>
|
||||
for (unsigned i=0; i<a.size(); ++i) {<BR>
|
||||
++a[i];<BR>
|
||||
}<BR>
|
||||
PRINT_ELEMENTS(a);<BR>
|
||||
<BR>
|
||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// change order using an STL algorithm</FONT></I><BR>
|
||||
reverse(a.begin(),a.end());<BR>
|
||||
PRINT_ELEMENTS(a);<BR>
|
||||
<BR>
|
||||
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// negate elements using STL framework</FONT></I><BR>
|
||||
transform(a.begin(),a.end(), <I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// source</FONT></I><BR>
|
||||
a.begin(), <I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// destination</FONT></I><BR>
|
||||
negate<int>()); <I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >// operation</FONT></I><BR>
|
||||
PRINT_ELEMENTS(a);<BR>
|
||||
}<BR>
|
||||
<BR>
|
||||
</SPAN>
|
||||
</TT>
|
||||
</BODY>
|
||||
</HTML>
|
Reference in New Issue
Block a user