Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bad97183153701b09df5fae1052b1c30 > files > 4345

crystalspace-doc-1.2.1-5mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created by texi2html 1.76 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>

-->
<head>
<title>Crystal Space 1.2.1: 4.6.2.1 Typed Arrays</title>

<meta name="description" content="Crystal Space 1.2.1: 4.6.2.1 Typed Arrays">
<meta name="keywords" content="Crystal Space 1.2.1: 4.6.2.1 Typed Arrays">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.76">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

<a name="Typed-Arrays"></a>
<a name="0"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="csUtil.html#0" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="Threading.html#0" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="Using-Crystal-Space.html#0" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="csUtil.html#0" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Working-with-Engine-Content.html#0" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="index.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="cs_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="cs_Index.html#0" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="cs_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<hr size="1">
<h4 class="subsubsection"> 4.6.2.1 Typed Arrays </h4>

<p>Crystal Space currently has several styles of typed arrays.  These arrays grow
as needed to accommodate additions and insertions.
</p>
<ul class="toc">
<li>
<code>csArray&lt;T&gt;</code>: This is a generic, all-purpose dynamic array class.  It is
suitable for any C++ type, including basic types (such as <samp>&lsquo;int&rsquo;</samp>) and
user-defined types (such as objects).  This class guarantees proper
construction and destruction of objects as they are added to, and removed from
the array. The array types described below are all derived from
<code>csArray&lt;T&gt;</code>. See <tt>&lsquo;csutil/array.h&rsquo;</tt>.

</li><li>
<code>csDirtyAccessArray&lt;T&gt;</code>: Similar to <code>csArray&lt;T&gt;</code>, this array type can
be used to store arbitrary objects. The difference is that this array allows
access to the raw memory block, via <code>GetArray()</code>, in which the elements
are stored, whereas <code>csArray&lt;T&gt;</code> keeps its internal state private.
Accessing the raw memory containing the elements is considered dangerous and
poor practice, so use of this class should be restricted and avoided.  Its main
use is when you absolutely need access to the internal memory containing the
array of items.  This can be useful, for instance, if you need to interface
with some external <small>API</small> (such as OpenGL) which does not understand
<code>csArray&lt;&gt;</code>, and which expects a simple pointer to the array elements.
See <tt>&lsquo;csutil/dirtyaccessarray.h&rsquo;</tt>.

</li><li>
<code>csRefArray&lt;T&gt;</code>: This is the preferred way to store an array of pointers
to reference-counted objects.  This array type automatically invokes each
object's <code>IncRef()</code> method at insertion time, and <code>DecRef()</code> at
removal time.  All <small>SCF</small> objects (see section <a href="SCF.html#0">Shared Class Facility (<small>SCF</small>)</a>) support these methods, as do
objects derived from <samp>&lsquo;csRefCount&rsquo;</samp>.  Since <code>csRefArray&lt;T&gt;</code> is a
templated class, it will also work with any other object which provides
<code>IncRef()</code> and <code>DecRef()</code> methods.  See <tt>&lsquo;csutil/refarr.h&rsquo;</tt>.

</li><li>
<code>csRefArrayObject&lt;T&gt;</code>: This is a variant of <code>csRefArray&lt;T&gt;</code> which can
hold objects that have a method <code>QueryObject()</code> which returns something
from which you can call <code>GetName()</code>.  In practice it means this is useful
for all Crystal Space objects which implement <samp>&lsquo;iObject&rsquo;</samp>.  In addition to
the features of <code>csRefArray&lt;T&gt;</code> this class adds the ability to find
elements by name.  See <tt>&lsquo;csutil/nobjvec.h&rsquo;</tt>.

</li><li>
<code>csPDelArray&lt;T&gt;</code>: This is a convenience array class for pointers only.  It
will invoke <samp>&lsquo;delete&rsquo;</samp> for elements removed from the array. This is useful
for cases when you need to store raw pointers to objects which have been
allocated with <samp>&lsquo;new&rsquo;</samp>, and don't want to worry about having to
<samp>&lsquo;delete&rsquo;</samp> the objects when removed from the array or when the array is
destroyed. In other cases where you need to store raw object pointers but don't
want them deleted upon removal from the array, just use the normal
<code>csArray&lt;T*&gt;</code>. See <tt>&lsquo;csutil/parray.h&rsquo;</tt>.
</li></ul>

<hr size="1">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="csUtil.html#0" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="Threading.html#0" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="Using-Crystal-Space.html#0" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="csUtil.html#0" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Working-with-Engine-Content.html#0" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="index.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="cs_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="cs_Index.html#0" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="cs_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
 <font size="-1">
  This document was generated using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.
 </font>
 <br>

</p>
</body>
</html>