diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-08 12:31:36 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-08 12:31:36 -0600 |
commit | d796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch) | |
tree | 6e3dcca4f77e20ec8966c666aac7c35bd4704053 /doc/html/qmemarray.html | |
download | tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip |
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'doc/html/qmemarray.html')
-rw-r--r-- | doc/html/qmemarray.html | 561 |
1 files changed, 561 insertions, 0 deletions
diff --git a/doc/html/qmemarray.html b/doc/html/qmemarray.html new file mode 100644 index 000000000..4fcdc305e --- /dev/null +++ b/doc/html/qmemarray.html @@ -0,0 +1,561 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/qmemarray.doc:41 --> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>TQMemArray Class</title> +<style type="text/css"><!-- +fn { margin-left: 1cm; text-indent: -1cm; } +a:link { color: #004faf; text-decoration: none } +a:visited { color: #672967; text-decoration: none } +body { background: #ffffff; color: black; } +--></style> +</head> +<body> + +<table border="0" cellpadding="0" cellspacing="0" width="100%"> +<tr bgcolor="#E5E5E5"> +<td valign=center> + <a href="index.html"> +<font color="#004faf">Home</font></a> + | <a href="classes.html"> +<font color="#004faf">All Classes</font></a> + | <a href="mainclasses.html"> +<font color="#004faf">Main Classes</font></a> + | <a href="annotated.html"> +<font color="#004faf">Annotated</font></a> + | <a href="groups.html"> +<font color="#004faf">Grouped Classes</font></a> + | <a href="functions.html"> +<font color="#004faf">Functions</font></a> +</td> +<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQMemArray Class Reference</h1> + +<p>The TQMemArray class is a template class that provides arrays of simple types. +<a href="#details">More...</a> +<p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when TQt is built with thread support.</p> +<p><tt>#include <<a href="qmemarray-h.html">qmemarray.h</a>></tt> +<p>Inherited by <a href="qbytearray.html">TQByteArray</a> and <a href="qpointarray.html">TQPointArray</a>. +<p><a href="qmemarray-members.html">List of all member functions.</a> +<h2>Public Members</h2> +<ul> +<li class=fn>typedef type * <a href="#Iterator"><b>Iterator</b></a></li> +<li class=fn>typedef const type * <a href="#ConstIterator"><b>ConstIterator</b></a></li> +<li class=fn><a href="#TQMemArray-2"><b>TQMemArray</b></a> ()</li> +<li class=fn><a href="#TQMemArray-3"><b>TQMemArray</b></a> ( int size )</li> +<li class=fn><a href="#TQMemArray-4"><b>TQMemArray</b></a> ( const TQMemArray<type> & a )</li> +<li class=fn><a href="#~TQMemArray"><b>~TQMemArray</b></a> ()</li> +<li class=fn>TQMemArray<type> & <a href="#operator-eq"><b>operator=</b></a> ( const TQMemArray<type> & a )</li> +<li class=fn>type * <a href="#data"><b>data</b></a> () const</li> +<li class=fn>uint <a href="#nrefs"><b>nrefs</b></a> () const</li> +<li class=fn>uint <a href="#size"><b>size</b></a> () const</li> +<li class=fn>uint <a href="#count"><b>count</b></a> () const</li> +<li class=fn>bool <a href="#isEmpty"><b>isEmpty</b></a> () const</li> +<li class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</li> +<li class=fn>bool <a href="#resize-2"><b>resize</b></a> ( uint size )</li> +<li class=fn>bool <a href="#resize"><b>resize</b></a> ( uint size, Optimization optim )</li> +<li class=fn>bool <a href="#truncate"><b>truncate</b></a> ( uint pos )</li> +<li class=fn>bool <a href="#fill"><b>fill</b></a> ( const type & v, int size = -1 )</li> +<li class=fn>virtual void <a href="#detach"><b>detach</b></a> ()</li> +<li class=fn>TQMemArray<type> <a href="#copy"><b>copy</b></a> () const</li> +<li class=fn>TQMemArray<type> & <a href="#assign"><b>assign</b></a> ( const TQMemArray<type> & a )</li> +<li class=fn>TQMemArray<type> & <a href="#assign-2"><b>assign</b></a> ( const type * data, uint size )</li> +<li class=fn>TQMemArray<type> & <a href="#duplicate"><b>duplicate</b></a> ( const TQMemArray<type> & a )</li> +<li class=fn>TQMemArray<type> & <a href="#duplicate-2"><b>duplicate</b></a> ( const type * data, uint size )</li> +<li class=fn>TQMemArray<type> & <a href="#setRawData"><b>setRawData</b></a> ( const type * data, uint size )</li> +<li class=fn>void <a href="#resetRawData"><b>resetRawData</b></a> ( const type * data, uint size )</li> +<li class=fn>int <a href="#find"><b>find</b></a> ( const type & v, uint index = 0 ) const</li> +<li class=fn>int <a href="#contains"><b>contains</b></a> ( const type & v ) const</li> +<li class=fn>void <a href="#sort"><b>sort</b></a> ()</li> +<li class=fn>int <a href="#bsearch"><b>bsearch</b></a> ( const type & v ) const</li> +<li class=fn>type & <a href="#operator[]"><b>operator[]</b></a> ( int index ) const</li> +<li class=fn>type & <a href="#at"><b>at</b></a> ( uint index ) const</li> +<li class=fn><a href="#operator-const-type-*"><b>operator const type *</b></a> () const</li> +<li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const TQMemArray<type> & a ) const</li> +<li class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const TQMemArray<type> & a ) const</li> +<li class=fn>Iterator <a href="#begin"><b>begin</b></a> ()</li> +<li class=fn>Iterator <a href="#end"><b>end</b></a> ()</li> +<li class=fn>ConstIterator <a href="#begin-2"><b>begin</b></a> () const</li> +<li class=fn>ConstIterator <a href="#end-2"><b>end</b></a> () const</li> +</ul> +<h2>Protected Members</h2> +<ul> +<li class=fn><a href="#TQMemArray"><b>TQMemArray</b></a> ( int, int )</li> +</ul> +<h2>Related Functions</h2> +<ul> +<li class=fn>Q_UINT16 <a href="#qChecksum"><b>qChecksum</b></a> ( const char * data, uint len )</li> +<li class=fn>TQDataStream & <a href="#operator-lt-lt"><b>operator<<</b></a> ( TQDataStream & s, const TQByteArray & a )</li> +<li class=fn>TQDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( TQDataStream & s, TQByteArray & a )</li> +</ul> +<hr><a name="details"></a><h2>Detailed Description</h2> + + + +The TQMemArray class is a template class that provides arrays of simple types. +<p> +<p> TQMemArray is implemented as a template class. Define a template +instance TQMemArray<X> to create an array that contains X items. +<p> TQMemArray stores the array elements directly in the array. It can +only deal with simple types (i.e. C++ types, structs, and classes +that have no constructors, destructors, or virtual functions). +TQMemArray uses bitwise operations to copy and compare array +elements. +<p> The <a href="qptrvector.html">TQPtrVector</a> collection class is also a kind of array. Like most +<a href="collection.html">collection classes</a>, it uses pointers +to the contained items. +<p> TQMemArray uses <a href="shclass.html">explicit sharing</a> with a +reference count. If more than one array shares common data and one +of the arrays is modified, all the arrays are modified. +<p> The benefit of sharing is that a program does not need to duplicate +data when it is not retquired, which results in lower memory use +and less copying of data. +<p> An alternative to TQMemArray is <a href="qvaluevector.html">TQValueVector</a>. The TQValueVector class +also provides an array of objects, but can deal with objects that +have constructors (specifically a copy constructor and a default +constructor). TQValueVector provides an STL-compatible syntax and is +<a href="shclass.html">implicitly shared</a>. +<p> Example: +<pre> + #include <<a href="qmemarray-h.html">qmemarray.h</a>> + #include <stdio.h> + + TQMemArray<int> fib( int num ) // returns fibonacci array + { + <a href="qapplication.html#Q_ASSERT">Q_ASSERT</a>( num > 2 ); + TQMemArray<int> f( num ); // array of ints + + f[0] = f[1] = 1; + for ( int i = 2; i < num; i++ ) + f[i] = f[i-1] + f[i-2]; + + return f; + } + + int main() + { + TQMemArray<int> a = fib( 6 ); // get first 6 fibonaccis + for ( int i = 0; i < a.<a href="#size">size</a>(); i++ ) + <a href="qapplication.html#qDebug">qDebug</a>( "%d: %d", i, a[i] ); + + <a href="qapplication.html#qDebug">qDebug</a>( "1 is found %d times", a.<a href="#contains">contains</a>(1) ); + <a href="qapplication.html#qDebug">qDebug</a>( "5 is found at index %d", a.<a href="#find">find</a>(5) ); + + return 0; + } + </pre> + +<p> Program output: +<pre> + 0: 1 + 1: 1 + 2: 2 + 3: 3 + 4: 5 + 5: 8 + 1 is found 2 times + 5 is found at index 4 + </pre> + +<p> Note concerning the use of TQMemArray for manipulating structs or +classes: Compilers will often pad the size of structs of odd sizes +up to the nearest word boundary. This will then be the size +TQMemArray will use for its bitwise element comparisons. Because +the remaining bytes will typically be uninitialized, this can +cause <a href="#find">find</a>() etc. to fail to find the element. Example: +<p> <pre> + // MyStruct may be padded to 4 or 8 bytes + struct MyStruct + { + short i; // 2 bytes + char c; // 1 byte + }; + + TQMemArray<MyStruct> a(1); + a[0].i = 5; + a[0].c = 't'; + + MyStruct x; + x.i = '5'; + x.c = 't'; + int i = a.<a href="#find">find</a>( x ); // may return -1 if the pad bytes differ + </pre> + +<p> To work around this, make sure that you use a struct where +sizeof() returns the same as the sum of the sizes of the members +either by changing the types of the struct members or by adding +dummy members. +<p> TQMemArray data can be traversed by iterators (see <a href="#begin">begin</a>() and +<a href="#end">end</a>()). The number of items is returned by <a href="#count">count</a>(). The array can +be resized with <a href="#resize">resize</a>() and filled using <a href="#fill">fill</a>(). +<p> You can make a <a href="shclass.html#shallow-copy">shallow copy</a> of the array with <a href="#assign">assign</a>() (or +<a href="#operator-eq">operator=</a>()) and a <a href="shclass.html#deep-copy">deep copy</a> with <a href="#duplicate">duplicate</a>(). +<p> Search for values in the array with <a href="#find">find</a>() and <a href="#contains">contains</a>(). For +sorted arrays (see <a href="#sort">sort</a>()) you can search using <a href="#bsearch">bsearch</a>(). +<p> You can set the data directly using <a href="#setRawData">setRawData</a>() and +<a href="#resetRawData">resetRawData</a>(), although this retquires care. +<p> <p>See also <a href="shclass.html">Shared Classes</a> and <a href="tools.html">Non-GUI Classes</a>. + +<hr><h2>Member Type Documentation</h2> +<h3 class=fn><a name="ConstIterator"></a>TQMemArray::ConstIterator</h3> +A const TQMemArray iterator. +<p>See also <a href="#begin">begin</a>() and <a href="#end">end</a>(). + +<h3 class=fn><a name="Iterator"></a>TQMemArray::Iterator</h3> +A TQMemArray iterator. +<p>See also <a href="#begin">begin</a>() and <a href="#end">end</a>(). + +<hr><h2>Member Function Documentation</h2> +<h3 class=fn><a name="TQMemArray"></a>TQMemArray::TQMemArray ( int, int )<tt> [protected]</tt> +</h3> + +<p> Constructs an array <em>without allocating</em> array space. The +arguments should be (0, 0). Use at your own risk. + +<h3 class=fn><a name="TQMemArray-2"></a>TQMemArray::TQMemArray () +</h3> + +<p> Constructs a null array. +<p> <p>See also <a href="#isNull">isNull</a>(). + +<h3 class=fn><a name="TQMemArray-3"></a>TQMemArray::TQMemArray ( int size ) +</h3> + +<p> Constructs an array with room for <em>size</em> elements. Makes a null +array if <em>size</em> == 0. +<p> The elements are left uninitialized. +<p> <p>See also <a href="#resize">resize</a>() and <a href="#isNull">isNull</a>(). + +<h3 class=fn><a name="TQMemArray-4"></a>TQMemArray::TQMemArray ( const <a href="qmemarray.html">TQMemArray</a><type> & a ) +</h3> + +<p> Constructs a <a href="shclass.html#shallow-copy">shallow copy</a> of <em>a</em>. +<p> <p>See also <a href="#assign">assign</a>(). + +<h3 class=fn><a name="~TQMemArray"></a>TQMemArray::~TQMemArray () +</h3> + +<p> Dereferences the array data and deletes it if this was the last +reference. + +<h3 class=fn><a href="qmemarray.html">TQMemArray</a><type> & <a name="assign"></a>TQMemArray::assign ( const <a href="qmemarray.html">TQMemArray</a><type> & a ) +</h3> + +<p> <a href="shclass.html#shallow-copy">Shallow copy</a>. Dereferences the current array and references the +data contained in <em>a</em> instead. Returns a reference to this array. +<p> <p>See also <a href="#operator-eq">operator=</a>(). + +<h3 class=fn><a href="qmemarray.html">TQMemArray</a><type> & <a name="assign-2"></a>TQMemArray::assign ( const type * data, uint size ) +</h3> + +<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. +<p> <a href="shclass.html#shallow-copy">Shallow copy</a>. Dereferences the current array and references the +array data <em>data</em>, which contains <em>size</em> elements. Returns a +reference to this array. +<p> Do not delete <em>data</em> later; TQMemArray will call free() on it +at the right time. + +<h3 class=fn>type & <a name="at"></a>TQMemArray::at ( uint index ) const +</h3> + +<p> Returns a reference to the element at position <em>index</em> in the array. +<p> This can be used to both read and set an element. +<p> <p>See also <a href="#operator[]">operator[]</a>(). + +<h3 class=fn><a href="qmemarray.html#Iterator">Iterator</a> <a name="begin"></a>TQMemArray::begin () +</h3> + +<p> Returns an iterator pointing at the beginning of this array. This +iterator can be used in the same way as the iterators of +<a href="qvaluelist.html">TQValueList</a> and <a href="qmap.html">TQMap</a>, for example. + +<h3 class=fn><a href="qmemarray.html#ConstIterator">ConstIterator</a> <a name="begin-2"></a>TQMemArray::begin () const +</h3> + +<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. +<p> Returns a const iterator pointing at the beginning of this array. +This iterator can be used in the same way as the iterators of +<a href="qvaluelist.html">TQValueList</a> and <a href="qmap.html">TQMap</a>, for example. + +<h3 class=fn>int <a name="bsearch"></a>TQMemArray::bsearch ( const type & v ) const +</h3> + +<p> In a sorted array (as sorted by <a href="#sort">sort</a>()), finds the first +occurrence of <em>v</em> by using a binary search. For a sorted +array this is generally much faster than <a href="#find">find</a>(), which does +a linear search. +<p> Returns the position of <em>v</em>, or -1 if <em>v</em> could not be found. +<p> <p>See also <a href="#sort">sort</a>() and <a href="#find">find</a>(). + +<h3 class=fn>int <a name="contains"></a>TQMemArray::contains ( const type & v ) const +</h3> + +<p> Returns the number of times <em>v</em> occurs in the array. +<p> <p>See also <a href="#find">find</a>(). + +<h3 class=fn><a href="qmemarray.html">TQMemArray</a><type> <a name="copy"></a>TQMemArray::copy () const +</h3> + +<p> Returns a <a href="shclass.html#deep-copy">deep copy</a> of this array. +<p> <p>See also <a href="#detach">detach</a>() and <a href="#duplicate">duplicate</a>(). + +<h3 class=fn>uint <a name="count"></a>TQMemArray::count () const +</h3> + +<p> Returns the same as <a href="#size">size</a>(). +<p> <p>See also <a href="#size">size</a>(). + +<p>Example: <a href="scribble-example.html#x913">scribble/scribble.cpp</a>. +<h3 class=fn>type * <a name="data"></a>TQMemArray::data () const +</h3> + +<p> Returns a pointer to the actual array data. +<p> The array is a null array if <a href="#data">data</a>() == 0 (null pointer). +<p> <p>See also <a href="#isNull">isNull</a>(). + +<p>Examples: <a href="fileiconview-example.html#x855">fileiconview/qfileiconview.cpp</a> and <a href="networkprotocol-example.html#x671">network/networkprotocol/nntp.cpp</a>. +<h3 class=fn>void <a name="detach"></a>TQMemArray::detach ()<tt> [virtual]</tt> +</h3> + +<p> Detaches this array from shared array data; i.e. it makes a +private, <a href="shclass.html#deep-copy">deep copy</a> of the data. +<p> Copying will be performed only if the <a href="#nrefs">reference + count</a> is greater than one. +<p> <p>See also <a href="#copy">copy</a>(). + +<p>Reimplemented in <a href="qbitarray.html#detach">TQBitArray</a>. +<h3 class=fn><a href="qmemarray.html">TQMemArray</a><type> & <a name="duplicate"></a>TQMemArray::duplicate ( const <a href="qmemarray.html">TQMemArray</a><type> & a ) +</h3> + +<p> <a href="shclass.html#deep-copy">Deep copy</a>. Dereferences the current array and obtains a copy of +the data contained in <em>a</em> instead. Returns a reference to this +array. +<p> <p>See also <a href="#copy">copy</a>(). + +<h3 class=fn><a href="qmemarray.html">TQMemArray</a><type> & <a name="duplicate-2"></a>TQMemArray::duplicate ( const type * data, uint size ) +</h3> + +<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. +<p> <a href="shclass.html#deep-copy">Deep copy</a>. Dereferences the current array and obtains a copy of +the array data <em>data</em> instead. Returns a reference to this array. +The size of the array is given by <em>size</em>. +<p> <p>See also <a href="#copy">copy</a>(). + +<h3 class=fn><a href="qmemarray.html#Iterator">Iterator</a> <a name="end"></a>TQMemArray::end () +</h3> + +<p> Returns an iterator pointing behind the last element of this +array. This iterator can be used in the same way as the iterators +of <a href="qvaluelist.html">TQValueList</a> and <a href="qmap.html">TQMap</a>, for example. + +<h3 class=fn><a href="qmemarray.html#ConstIterator">ConstIterator</a> <a name="end-2"></a>TQMemArray::end () const +</h3> + +<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. +<p> Returns a const iterator pointing behind the last element of this +array. This iterator can be used in the same way as the iterators +of <a href="qvaluelist.html">TQValueList</a> and <a href="qmap.html">TQMap</a>, for example. + +<h3 class=fn>bool <a name="fill"></a>TQMemArray::fill ( const type & v, int size = -1 ) +</h3> + +<p> Fills the array with the value <em>v</em>. If <em>size</em> is specified as +different from -1, then the array will be resized before being +filled. +<p> Returns TRUE if successful, i.e. if <em>size</em> is -1, or <em>size</em> is +!= -1 and the memory can be allocated; otherwise returns FALSE. +<p> <p>See also <a href="#resize">resize</a>(). + +<h3 class=fn>int <a name="find"></a>TQMemArray::find ( const type & v, uint index = 0 ) const +</h3> + +<p> Finds the first occurrence of <em>v</em>, starting at position <em>index</em>. +<p> Returns the position of <em>v</em>, or -1 if <em>v</em> could not be found. +<p> <p>See also <a href="#contains">contains</a>(). + +<h3 class=fn>bool <a name="isEmpty"></a>TQMemArray::isEmpty () const +</h3> + +<p> Returns TRUE if the array is empty; otherwise returns FALSE. +<p> <a href="#isEmpty">isEmpty</a>() is equivalent to <a href="#isNull">isNull</a>() for TQMemArray (unlike +<a href="qstring.html">TQString</a>). + +<h3 class=fn>bool <a name="isNull"></a>TQMemArray::isNull () const +</h3> + +<p> Returns TRUE if the array is null; otherwise returns FALSE. +<p> A null array has <a href="#size">size</a>() == 0 and <a href="#data">data</a>() == 0. + +<h3 class=fn>uint <a name="nrefs"></a>TQMemArray::nrefs () const +</h3> + +<p> Returns the reference count for the shared array data. This +reference count is always greater than zero. + +<h3 class=fn><a name="operator-const-type-*"></a>TQMemArray::operator const type * () const +</h3> + +<p> Cast operator. Returns a pointer to the array. +<p> <p>See also <a href="#data">data</a>(). + +<h3 class=fn>bool <a name="operator!-eq"></a>TQMemArray::operator!= ( const <a href="qmemarray.html">TQMemArray</a><type> & a ) const +</h3> + +<p> Returns TRUE if this array is different from <em>a</em>; otherwise +returns FALSE. +<p> The two arrays are compared bitwise. +<p> <p>See also <a href="#operator-eq-eq">operator==</a>(). + +<h3 class=fn><a href="qmemarray.html">TQMemArray</a><type> & <a name="operator-eq"></a>TQMemArray::operator= ( const <a href="qmemarray.html">TQMemArray</a><type> & a ) +</h3> + +<p> Assigns a <a href="shclass.html#shallow-copy">shallow copy</a> of <em>a</em> to this array and returns a +reference to this array. +<p> Equivalent to <a href="#assign">assign</a>( a ). + +<h3 class=fn>bool <a name="operator-eq-eq"></a>TQMemArray::operator== ( const <a href="qmemarray.html">TQMemArray</a><type> & a ) const +</h3> + +<p> Returns TRUE if this array is equal to <em>a</em>; otherwise returns +FALSE. +<p> The two arrays are compared bitwise. +<p> <p>See also <a href="#operator!-eq">operator!=</a>(). + +<h3 class=fn>type & <a name="operator[]"></a>TQMemArray::operator[] ( int index ) const +</h3> + +<p> Returns a reference to the element at position <em>index</em> in the +array. +<p> This can be used to both read and set an element. Equivalent to +<a href="#at">at</a>(). +<p> <p>See also <a href="#at">at</a>(). + +<h3 class=fn>void <a name="resetRawData"></a>TQMemArray::resetRawData ( const type * data, uint size ) +</h3> + +<p> Removes internal references to the raw data that was set using +<a href="#setRawData">setRawData</a>(). This means that TQMemArray no longer has access to +the <em>data</em>, so you are free to manipulate <em>data</em> as you wish. +You can now use the TQMemArray without affecting the original <em>data</em>, for example by calling setRawData() with a pointer to some +other data. +<p> The arguments must be the <em>data</em> and length, <em>size</em>, that were +passed to setRawData(). This is for consistency checking. +<p> <p>See also <a href="#setRawData">setRawData</a>(). + +<h3 class=fn>bool <a name="resize"></a>TQMemArray::resize ( uint size, Optimization optim ) +</h3> + +<p> Resizes (expands or shrinks) the array to <em>size</em> elements. The +array becomes a null array if <em>size</em> == 0. +<p> Returns TRUE if successful, or FALSE if the memory cannot be +allocated. +<p> New elements are not initialized. +<p> <em>optim</em> is either <tt>TQGArray::MemOptim</tt> (the default) or +<tt>TQGArray::SpeedOptim</tt>. +<p> <b>Note:</b> By default, <tt>SpeedOptim</tt> is not available for general +use since it is only available if TQt is built in a particular +configuration. +<p> <p>See also <a href="#size">size</a>(). + +<p>Example: <a href="fileiconview-example.html#x856">fileiconview/qfileiconview.cpp</a>. +<h3 class=fn>bool <a name="resize-2"></a>TQMemArray::resize ( uint size ) +</h3> + +<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. +<p> Resizes (expands or shrinks) the array to <em>size</em> elements. The +array becomes a null array if <em>size</em> == 0. +<p> Returns TRUE if successful, i.e. if the memory can be allocated; +otherwise returns FALSE. +<p> New elements are not initialized. +<p> <p>See also <a href="#size">size</a>(). + +<h3 class=fn><a href="qmemarray.html">TQMemArray</a><type> & <a name="setRawData"></a>TQMemArray::setRawData ( const type * data, uint size ) +</h3> + +<p> Sets raw data and returns a reference to the array. +<p> Dereferences the current array and sets the new array data to <em>data</em> and the new array size to <em>size</em>. Do not attempt to resize +or re-assign the array data when raw data has been set. Call +<a href="#resetRawData">resetRawData</a>(<em>data</em>, <em>size</em>) to reset the array. +<p> Setting raw data is useful because it sets TQMemArray data without +allocating memory or copying data. +<p> Example I (intended use): +<pre> + static char bindata[] = { 231, 1, 44, ... }; + <a href="qbytearray.html">TQByteArray</a> a; + a.<a href="#setRawData">setRawData</a>( bindata, sizeof(bindata) ); // a points to bindata + <a href="qdatastream.html">TQDataStream</a> s( a, <a href="qfile.html#open">IO_ReadOnly</a> ); // open on a's data + s >> <something>; // read raw bindata + a.<a href="#resetRawData">resetRawData</a>( bindata, sizeof(bindata) ); // finished + </pre> + +<p> Example II (you don't want to do this): +<pre> + static char bindata[] = { 231, 1, 44, ... }; + <a href="qbytearray.html">TQByteArray</a> a, b; + a.<a href="#setRawData">setRawData</a>( bindata, sizeof(bindata) ); // a points to bindata + a.<a href="#resize">resize</a>( 8 ); // will crash + b = a; // will crash + a[2] = 123; // might crash + // forget to resetRawData: will crash + </pre> + +<p> <b>Warning:</b> If you do not call <a href="#resetRawData">resetRawData</a>(), TQMemArray will attempt +to deallocate or reallocate the raw data, which might not be too +good. Be careful. +<p> <p>See also <a href="#resetRawData">resetRawData</a>(). + +<h3 class=fn>uint <a name="size"></a>TQMemArray::size () const +</h3> + +<p> Returns the size of the array (maximum number of elements). +<p> The array is a null array if <a href="#size">size</a>() == 0. +<p> <p>See also <a href="#isNull">isNull</a>() and <a href="#resize">resize</a>(). + +<h3 class=fn>void <a name="sort"></a>TQMemArray::sort () +</h3> + +<p> Sorts the array elements in ascending order, using bitwise +comparison (memcmp()). +<p> <p>See also <a href="#bsearch">bsearch</a>(). + +<h3 class=fn>bool <a name="truncate"></a>TQMemArray::truncate ( uint pos ) +</h3> + +<p> Truncates the array at position <em>pos</em>. +<p> Returns TRUE if successful, i.e. if the memory can be allocated; +otherwise returns FALSE. +<p> Equivalent to <a href="#resize">resize</a>(<em>pos</em>). +<p> <p>See also <a href="#resize">resize</a>(). + +<hr><h2>Related Functions</h2> +<h3 class=fn><a href="qdatastream.html">TQDataStream</a> & <a name="operator-lt-lt"></a>operator<< ( <a href="qdatastream.html">TQDataStream</a> & s, const <a href="qbytearray.html">TQByteArray</a> & a ) +</h3> + +<p> Writes byte array <em>a</em> to the stream <em>s</em> and returns a reference +to the stream. +<p> <p>See also <a href="datastreamformat.html">Format of the TQDataStream operators</a>. + +<h3 class=fn><a href="qdatastream.html">TQDataStream</a> & <a name="operator-gt-gt"></a>operator>> ( <a href="qdatastream.html">TQDataStream</a> & s, <a href="qbytearray.html">TQByteArray</a> & a ) +</h3> + +<p> Reads a byte array into <em>a</em> from the stream <em>s</em> and returns a +reference to the stream. +<p> <p>See also <a href="datastreamformat.html">Format of the TQDataStream operators</a>. + +<h3 class=fn>Q_UINT16 <a name="qChecksum"></a>qChecksum ( const char * data, uint len ) +</h3> + +<p> Returns the CRC-16 checksum of <em>len</em> bytes starting at <em>data</em>. +<p> The checksum is independent of the byte order (endianness). + +<!-- eof --> +<hr><p> +This file is part of the <a href="index.html">TQt toolkit</a>. +Copyright © 1995-2007 +<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center> +<table width=100% cellspacing=0 border=0><tr> +<td>Copyright © 2007 +<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a> +<td align=right><div align=right>TQt 3.3.8</div> +</table></div></address></body> +</html> |