1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>wxWidgets: wxArray< T > Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="page_container">
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0" style="width: 100%;">
<tbody>
<tr>
<td id="projectlogo">
<a href="http://www.wxwidgets.org/" target="_new">
<img alt="wxWidgets" src="logo.png"/>
</a>
</td>
<td style="padding-left: 0.5em; text-align: right;">
<span id="projectnumber">Version: 3.0.2</span>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.8.2 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Categories</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="classes.html"><span>Class Index</span></a></li>
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="classwx_array_3_01_t_01_4-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">wxArray< T > Class Template Reference<div class="ingroups"><a class="el" href="group__group__class__containers.html">Containers</a></div></div> </div>
</div><!--header-->
<div class="contents">
<p><code>#include <wx/dynarray.h></code></p>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template<typename T><br/>
class wxArray< T ></h3>
<p>This section describes the so called <em>"dynamic arrays"</em>. </p>
<p>This is a C array-like type safe data structure i.e. the member access time is constant (and not linear according to the number of container elements as for linked lists). However, these arrays are dynamic in the sense that they will automatically allocate more memory if there is not enough of it for adding a new element. They also perform range checking on the index values but in debug mode only, so please be sure to compile your application in debug mode to use it (see <a class="el" href="overview_debugging.html">Debugging</a> for details). So, unlike the arrays in some other languages, attempt to access an element beyond the arrays bound doesn't automatically expand the array but provokes an assertion failure instead in debug build and does nothing (except possibly crashing your program) in the release build.</p>
<p>The array classes were designed to be reasonably efficient, both in terms of run-time speed and memory consumption and the executable size. The speed of array item access is, of course, constant (independent of the number of elements) making them much more efficient than linked lists (wxList). Adding items to the arrays is also implemented in more or less constant time, but the price is preallocating the memory in advance. In the "memory management" function section, you may find some useful hints about optimizing wxArray memory usage. As for executable size, all wxArray functions are inline, so they do not take <em>any</em> space at all.</p>
<p>wxWidgets has three different kinds of array. All of them derive from wxBaseArray class which works with untyped data and cannot be used directly. The standard macros <a class="el" href="dynarray_8h.html#aa9c653860ef656116ad6914e79e17340" title="This macro defines a new array class named name and containing the elements of type T...">WX_DEFINE_ARRAY()</a>, <a class="el" href="dynarray_8h.html#a12e1e3d31fcc7973cff20edfaadd8473" title="This macro defines a new sorted array class named name and containing the elements of type T...">WX_DEFINE_SORTED_ARRAY()</a> and <a class="el" href="dynarray_8h.html#a52cebddf0dbdeb2d7dbbfb88656f0f79" title="This macro defines the methods of the array class name not defined by the WX_DECLARE_OBJARRAY() macro...">WX_DEFINE_OBJARRAY()</a> are used to define a new class deriving from it. The classes declared will be called in this documentation wxArray, wxSortedArray and wxObjArray but you should keep in mind that no classes with such names actually exist, each time you use one of the WX_DEFINE_XXXARRAY() macros, you define a class with a new name. In fact, these names are "template" names and each usage of one of the macros mentioned above creates a template specialization for the given element type.</p>
<p>wxArray is suitable for storing integer types and pointers which it does not treat as objects in any way, i.e. the element pointed to by the pointer is not deleted when the element is removed from the array. It should be noted that all of wxArray's functions are inline, so it costs strictly nothing to define as many array types as you want (either in terms of the executable size or the speed) as long as at least one of them is defined and this is always the case because wxArrays are used by wxWidgets internally. This class has one serious limitation: it can only be used for storing integral types (bool, char, short, int, long and their unsigned variants) or pointers (of any kind). An attempt to use with objects of <code>sizeof()</code> greater than <code>sizeof(long)</code> will provoke a runtime assertion failure, however declaring a wxArray of floats will not (on the machines where <code>"sizeof(float) <= sizeof(long)"</code>), yet it will <b>not</b> work, please use wxObjArray for storing floats and doubles.</p>
<p>wxSortedArray is a wxArray variant which should be used when searching in the array is a frequently used operation. It requires you to define an additional function for comparing two elements of the array element type and always stores its items in the sorted order (according to this function). Thus, its <a class="el" href="classwx_array_3_01_t_01_4.html#a9627dd7d9eba85d25a4aa1b666ab9a9c" title="This version of Index() is for wxArray and wxObjArray only.">Index()</a> function execution time is <code>"O(log(N))"</code> instead of <code>"O(N)"</code> for the usual arrays but the <a class="el" href="classwx_array_3_01_t_01_4.html#a0fd8856be5662cb7f07894cf9a318dda" title="Appends the given number of copies of the item to the array consisting of the elements of type T...">Add()</a> method is slower: it is <code>"O(log(N))"</code> instead of constant time (neglecting time spent in memory allocation routine). However, in a usual situation elements are added to an array much less often than searched inside it, so wxSortedArray may lead to huge performance improvements compared to wxArray. Finally, it should be noticed that, as wxArray, wxSortedArray can be only used for storing integral types or pointers.</p>
<p>wxObjArray class treats its elements like "objects". It may delete them when they are removed from the array (invoking the correct destructor) and copies them using the objects copy constructor. In order to implement this behaviour the definition of the wxObjArray arrays is split in two parts: first, you should declare the new wxObjArray class using the <a class="el" href="dynarray_8h.html#a515e9265b474d8a152ec3ec42179abde" title="This macro declares a new object array class named name and containing the elements of type T...">WX_DECLARE_OBJARRAY()</a> macro and then you must include the file defining the implementation of template type: <wx/arrimpl.cpp> and define the array class with the <a class="el" href="dynarray_8h.html#a52cebddf0dbdeb2d7dbbfb88656f0f79" title="This macro defines the methods of the array class name not defined by the WX_DECLARE_OBJARRAY() macro...">WX_DEFINE_OBJARRAY()</a> macro from a point where the full (as opposed to 'forward') declaration of the array elements class is in scope. As it probably sounds very complicated here is an example:</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include <<a class="code" href="dynarray_8h.html">wx/dynarray.h</a>></span></div>
<div class="line"></div>
<div class="line"><span class="comment">// We must forward declare the array because it is used</span></div>
<div class="line"><span class="comment">// inside the class declaration.</span></div>
<div class="line"><span class="keyword">class </span>MyDirectory;</div>
<div class="line"><span class="keyword">class </span>MyFile;</div>
<div class="line"></div>
<div class="line"><span class="comment">// This defines two new types: ArrayOfDirectories and ArrayOfFiles which</span></div>
<div class="line"><span class="comment">// can be now used as shown below.</span></div>
<div class="line"><a class="code" href="dynarray_8h.html#a515e9265b474d8a152ec3ec42179abde" title="This macro declares a new object array class named name and containing the elements of type T...">WX_DECLARE_OBJARRAY</a>(MyDirectory, ArrayOfDirectories);</div>
<div class="line"><a class="code" href="dynarray_8h.html#a515e9265b474d8a152ec3ec42179abde" title="This macro declares a new object array class named name and containing the elements of type T...">WX_DECLARE_OBJARRAY</a>(MyFile, ArrayOfFiles);</div>
<div class="line"></div>
<div class="line"><span class="keyword">class </span>MyDirectory</div>
<div class="line">{</div>
<div class="line"> <span class="comment">// ...</span></div>
<div class="line"> ArrayOfDirectories m_subdirectories; <span class="comment">// All subdirectories</span></div>
<div class="line"> ArrayOfFiles m_files; <span class="comment">// All files in this directory</span></div>
<div class="line">};</div>
<div class="line"></div>
<div class="line"><span class="comment">// ...</span></div>
<div class="line"></div>
<div class="line"><span class="comment">// Now that we have MyDirectory declaration in scope we may finish the</span></div>
<div class="line"><span class="comment">// definition of ArrayOfDirectories -- note that this expands into some C++</span></div>
<div class="line"><span class="comment">// code and so should only be compiled once (i.e., don't put this in the</span></div>
<div class="line"><span class="comment">// header, but into a source file or you will get linking errors)</span></div>
<div class="line"><span class="preprocessor">#include <wx/arrimpl.cpp></span> <span class="comment">// This is a magic incantation which must be done!</span></div>
<div class="line"><a class="code" href="dynarray_8h.html#a52cebddf0dbdeb2d7dbbfb88656f0f79" title="This macro defines the methods of the array class name not defined by the WX_DECLARE_OBJARRAY() macro...">WX_DEFINE_OBJARRAY</a>(ArrayOfDirectories);</div>
<div class="line"></div>
<div class="line"><span class="comment">// that's all!</span></div>
</div><!-- fragment --><p>It is not as elegant as writing this:</p>
<div class="fragment"><div class="line"><span class="keyword">typedef</span> std::vector<MyDirectory> ArrayOfDirectories;</div>
</div><!-- fragment --><p>But is not that complicated and allows the code to be compiled with any, however dumb, C++ compiler in the world.</p>
<p>Remember to include <wx/arrimpl.cpp> just before each <a class="el" href="dynarray_8h.html#a52cebddf0dbdeb2d7dbbfb88656f0f79" title="This macro defines the methods of the array class name not defined by the WX_DECLARE_OBJARRAY() macro...">WX_DEFINE_OBJARRAY()</a> occurrence in your code, even if you have several in the same file.</p>
<p>Things are much simpler for wxArray and wxSortedArray however: it is enough just to write:</p>
<div class="fragment"><div class="line">WX_DEFINE_ARRAY_INT(<span class="keywordtype">int</span>, ArrayOfInts);</div>
<div class="line">WX_DEFINE_SORTED_ARRAY_INT(<span class="keywordtype">int</span>, ArrayOfSortedInts);</div>
</div><!-- fragment --><p>There is only one <code>DEFINE</code> macro and no need for separate <code>DECLARE</code> one. For the arrays of the primitive types, the macros <code>WX_DEFINE_ARRAY_CHAR/SHORT/INT/SIZE_T/LONG/DOUBLE</code> should be used depending on the sizeof of the values (notice that storing values of smaller type, e.g. shorts, in an array of larger one, e.g. <code>ARRAY_INT</code>, does not work on all architectures!).</p>
<h1><a class="anchor" id="array_macros"></a>
Macros for Template Array Definition</h1>
<p>To use an array you must first define the array class. This is done with the help of the macros in this section. The class of array elements must be (at least) forward declared for <a class="el" href="dynarray_8h.html#aa9c653860ef656116ad6914e79e17340" title="This macro defines a new array class named name and containing the elements of type T...">WX_DEFINE_ARRAY()</a>, <a class="el" href="dynarray_8h.html#a12e1e3d31fcc7973cff20edfaadd8473" title="This macro defines a new sorted array class named name and containing the elements of type T...">WX_DEFINE_SORTED_ARRAY()</a> and <a class="el" href="dynarray_8h.html#a515e9265b474d8a152ec3ec42179abde" title="This macro declares a new object array class named name and containing the elements of type T...">WX_DECLARE_OBJARRAY()</a> macros and must be fully declared before you use <a class="el" href="dynarray_8h.html#a52cebddf0dbdeb2d7dbbfb88656f0f79" title="This macro defines the methods of the array class name not defined by the WX_DECLARE_OBJARRAY() macro...">WX_DEFINE_OBJARRAY()</a> macro.</p>
<ul>
<li><a class="el" href="dynarray_8h.html#aa9c653860ef656116ad6914e79e17340" title="This macro defines a new array class named name and containing the elements of type T...">WX_DEFINE_ARRAY()</a></li>
<li><a class="el" href="dynarray_8h.html#a32eb9d62c9479016d9662c510a7c8291" title="This macro defines a new array class named name and containing the elements of type T...">WX_DEFINE_EXPORTED_ARRAY()</a></li>
<li><a class="el" href="dynarray_8h.html#a3b9d36de8f94e2946dd96ae715572e88" title="This macro defines a new array class named name and containing the elements of type T...">WX_DEFINE_USER_EXPORTED_ARRAY()</a></li>
<li><a class="el" href="dynarray_8h.html#a12e1e3d31fcc7973cff20edfaadd8473" title="This macro defines a new sorted array class named name and containing the elements of type T...">WX_DEFINE_SORTED_ARRAY()</a></li>
<li><a class="el" href="dynarray_8h.html#ab304943d0f95d3b5d4494743dbb4b0f8" title="This macro defines a new sorted array class named name and containing the elements of type T...">WX_DEFINE_SORTED_EXPORTED_ARRAY()</a></li>
<li><a class="el" href="dynarray_8h.html#af01eea1165404d844c705ed6539b4bf3" title="This macro defines a new sorted array class named name and containing the elements of type T...">WX_DEFINE_SORTED_USER_EXPORTED_ARRAY()</a></li>
<li><a class="el" href="dynarray_8h.html#a6c4cbd97b2b8c79aef39d55f35686f96" title="This macro declares a new object array class named name and containing the elements of type T...">WX_DECLARE_EXPORTED_OBJARRAY()</a></li>
<li><a class="el" href="dynarray_8h.html#ab391af5040f754730afdf5b0fcfc211b" title="This macro declares a new object array class named name and containing the elements of type T...">WX_DECLARE_USER_EXPORTED_OBJARRAY()</a></li>
<li><a class="el" href="dynarray_8h.html#a52cebddf0dbdeb2d7dbbfb88656f0f79" title="This macro defines the methods of the array class name not defined by the WX_DECLARE_OBJARRAY() macro...">WX_DEFINE_OBJARRAY()</a></li>
<li><a class="el" href="dynarray_8h.html#ae05b2e13eddeb23ff7fdc5163f9d992e" title="This macro defines the methods of the array class name not defined by the WX_DECLARE_OBJARRAY() macro...">WX_DEFINE_EXPORTED_OBJARRAY()</a></li>
<li><a class="el" href="dynarray_8h.html#a2555ba53da045a79c54b1303f25d8a47" title="This macro defines the methods of the array class name not defined by the WX_DECLARE_OBJARRAY() macro...">WX_DEFINE_USER_EXPORTED_OBJARRAY()</a></li>
</ul>
<p>To slightly complicate the matters even further, the operator "->" defined by default for the array iterators by these macros only makes sense if the array element type is not a pointer itself and, although it still works, this provokes warnings from some compilers and to avoid them you should use the <code>_PTR</code> versions of the macros above. For example, to define an array of pointers to <code>double</code> you should use:</p>
<div class="fragment"><div class="line">WX_DEFINE_ARRAY_PTR(<span class="keywordtype">double</span> *, MyArrayOfDoublePointers);</div>
</div><!-- fragment --><p>Note that the above macros are generally only useful for <a class="el" href="classwx_object.html" title="This is the root class of many of the wxWidgets classes.">wxObject</a> types. There are separate macros for declaring an array of a simple type, such as an int.</p>
<p>The following simple types are supported:</p>
<ul>
<li><code>int</code> </li>
<li><code>long</code> </li>
<li><code>size_t</code> </li>
<li><code>double</code> </li>
</ul>
<p>To create an array of a simple type, simply append the type you want in CAPS to the array definition.</p>
<p>For example, you'd use one of the following variants for an integer array:</p>
<ul>
<li>WX_DEFINE_ARRAY_INT()</li>
<li>WX_DEFINE_EXPORTED_ARRAY_INT()</li>
<li>WX_DEFINE_USER_EXPORTED_ARRAY_INT()</li>
<li>WX_DEFINE_SORTED_ARRAY_INT()</li>
<li>WX_DEFINE_SORTED_EXPORTED_ARRAY_INT()</li>
<li>WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_INT()</li>
</ul>
<h1><a class="anchor" id="array_predef"></a>
Predefined array types</h1>
<p>wxWidgets defines the following dynamic array types:</p>
<ul>
<li><a class="el" href="dynarray_8h.html#a4d95651e563be2e44c507f5e1c1ebb13" title="Predefined specialization of wxArray<T> for standard types.">wxArrayShort</a></li>
<li><a class="el" href="dynarray_8h.html#add87f199292e36ee87efd6d7f0d4ee66" title="Predefined specialization of wxArray<T> for standard types.">wxArrayInt</a></li>
<li><a class="el" href="dynarray_8h.html#a84411c7d20ee889cd887dd10ef12b1a7" title="Predefined specialization of wxArray<T> for standard types.">wxArrayDouble</a></li>
<li><a class="el" href="dynarray_8h.html#aae5ab96217f8797a82373b4126a6b254" title="Predefined specialization of wxArray<T> for standard types.">wxArrayLong</a></li>
<li><a class="el" href="dynarray_8h.html#a6b7224fd0223439eed62c2fae09981d1" title="Predefined specialization of wxArray<T> for standard types.">wxArrayPtrVoid</a></li>
</ul>
<p>To use them you don't need any macro; you just need to include <code><a class="el" href="dynarray_8h.html">dynarray.h</a></code>.</p>
<h2></h2>
<div><span class="lib">Library:</span>  <span class="lib_text"><a class="el" href="page_libs.html#page_libs_wxbase">wxBase</a></span></div><div><span class="category">Category:</span>  <span class="category_text"><a class="el" href="group__group__class__containers.html">Containers</a></span></div><dl class="section see"><dt>See Also</dt><dd><a class="el" href="overview_container.html">Container Classes</a>, <a class="el" href="classwx_list_3_01_t_01_4.html" title="The wxList<T> class provides linked list functionality.">wxList<T></a>, <a class="el" href="classwx_vector_3_01_t_01_4.html" title="wxVector<T> is a template class which implements most of the std::vector class and can be used like i...">wxVector<T></a> </dd></dl>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td colspan="2"><div class="groupHeader">Constructors and Destructors</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>Array classes are 100% C++ objects and as such they have the appropriate copy constructors and assignment operators.</p>
<p>Copying wxArray just copies the elements but copying wxObjArray copies the arrays items. However, for memory-efficiency sake, neither of these classes has virtual destructor. It is not very important for wxArray which has trivial destructor anyhow, but it does mean that you should avoid deleting wxObjArray through a wxBaseArray pointer (as you would never use wxBaseArray anyhow it shouldn't be a problem) and that you should not derive your own classes from the array classes. </p>
</div></td></tr>
<tr class="memitem:a714c1ed4b8be1a8e7073ebe8ae387303"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a> ()</td></tr>
<tr class="memdesc:a714c1ed4b8be1a8e7073ebe8ae387303"><td class="mdescLeft"> </td><td class="mdescRight">Default constructor. <a href="#a714c1ed4b8be1a8e7073ebe8ae387303"></a><br/></td></tr>
<tr class="separator:a714c1ed4b8be1a8e7073ebe8ae387303"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:adff3fffdc4b2a51cb0ad4606114714ab"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#adff3fffdc4b2a51cb0ad4606114714ab">wxObjArray</a> ()</td></tr>
<tr class="memdesc:adff3fffdc4b2a51cb0ad4606114714ab"><td class="mdescLeft"> </td><td class="mdescRight">Default constructor initializes an empty array object. <a href="#adff3fffdc4b2a51cb0ad4606114714ab"></a><br/></td></tr>
<tr class="separator:adff3fffdc4b2a51cb0ad4606114714ab"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a7fcfbd2fa53fe042ea385f4e254729da"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a7fcfbd2fa53fe042ea385f4e254729da">wxSortedArray</a> (int(*)(T first, T second) compareFunction)</td></tr>
<tr class="memdesc:a7fcfbd2fa53fe042ea385f4e254729da"><td class="mdescLeft"> </td><td class="mdescRight">There is no default constructor for wxSortedArray classes - you must initialize it with a function to use for item comparison. <a href="#a7fcfbd2fa53fe042ea385f4e254729da"></a><br/></td></tr>
<tr class="separator:a7fcfbd2fa53fe042ea385f4e254729da"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ae6ce544f41797c2bca97507beca57b6c"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#ae6ce544f41797c2bca97507beca57b6c">wxArray</a> (const wxArray &array)</td></tr>
<tr class="memdesc:ae6ce544f41797c2bca97507beca57b6c"><td class="mdescLeft"> </td><td class="mdescRight">Performs a shallow array copy (i.e. doesn't copy the objects pointed to even if the source array contains the items of pointer type). <a href="#ae6ce544f41797c2bca97507beca57b6c"></a><br/></td></tr>
<tr class="separator:ae6ce544f41797c2bca97507beca57b6c"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a27baa04ffabb62aab9357e6c92a4d430"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a27baa04ffabb62aab9357e6c92a4d430">wxSortedArray</a> (const wxSortedArray &array)</td></tr>
<tr class="memdesc:a27baa04ffabb62aab9357e6c92a4d430"><td class="mdescLeft"> </td><td class="mdescRight">Performs a shallow array copy (i.e. doesn't copy the objects pointed to even if the source array contains the items of pointer type). <a href="#a27baa04ffabb62aab9357e6c92a4d430"></a><br/></td></tr>
<tr class="separator:a27baa04ffabb62aab9357e6c92a4d430"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a7379d427e1cf74eba4cdc27f44c7c682"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a7379d427e1cf74eba4cdc27f44c7c682">wxObjArray</a> (const wxObjArray &array)</td></tr>
<tr class="memdesc:a7379d427e1cf74eba4cdc27f44c7c682"><td class="mdescLeft"> </td><td class="mdescRight">Performs a deep copy (i.e. the array element are copied too). <a href="#a7379d427e1cf74eba4cdc27f44c7c682"></a><br/></td></tr>
<tr class="separator:a7379d427e1cf74eba4cdc27f44c7c682"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a713b8bad4b168eeaba235aad4b4ac562"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a713b8bad4b168eeaba235aad4b4ac562">operator=</a> (const <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a> &array)</td></tr>
<tr class="memdesc:a713b8bad4b168eeaba235aad4b4ac562"><td class="mdescLeft"> </td><td class="mdescRight">Performs a shallow array copy (i.e. doesn't copy the objects pointed to even if the source array contains the items of pointer type). <a href="#a713b8bad4b168eeaba235aad4b4ac562"></a><br/></td></tr>
<tr class="separator:a713b8bad4b168eeaba235aad4b4ac562"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a3480573120c8a425ca8aaee72462c469"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classwx_array_3_01_t_01_4.html#a7fcfbd2fa53fe042ea385f4e254729da">wxSortedArray</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a3480573120c8a425ca8aaee72462c469">operator=</a> (const <a class="el" href="classwx_array_3_01_t_01_4.html#a7fcfbd2fa53fe042ea385f4e254729da">wxSortedArray</a> &array)</td></tr>
<tr class="memdesc:a3480573120c8a425ca8aaee72462c469"><td class="mdescLeft"> </td><td class="mdescRight">Performs a shallow array copy (i.e. doesn't copy the objects pointed to even if the source array contains the items of pointer type). <a href="#a3480573120c8a425ca8aaee72462c469"></a><br/></td></tr>
<tr class="separator:a3480573120c8a425ca8aaee72462c469"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:afac88aa2fde976cb6e131369296843d2"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classwx_array_3_01_t_01_4.html#adff3fffdc4b2a51cb0ad4606114714ab">wxObjArray</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#afac88aa2fde976cb6e131369296843d2">operator=</a> (const <a class="el" href="classwx_array_3_01_t_01_4.html#adff3fffdc4b2a51cb0ad4606114714ab">wxObjArray</a> &array)</td></tr>
<tr class="memdesc:afac88aa2fde976cb6e131369296843d2"><td class="mdescLeft"> </td><td class="mdescRight">Performs a deep copy (i.e. the array element are copied too). <a href="#afac88aa2fde976cb6e131369296843d2"></a><br/></td></tr>
<tr class="separator:afac88aa2fde976cb6e131369296843d2"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a61cc6bbeef22f43d9604d00d0ec8f383"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a61cc6bbeef22f43d9604d00d0ec8f383">~wxArray</a> ()</td></tr>
<tr class="memdesc:a61cc6bbeef22f43d9604d00d0ec8f383"><td class="mdescLeft"> </td><td class="mdescRight">This destructor does not delete all the items owned by the array, you may use the <a class="el" href="dynarray_8h.html#a2057e24dceef760fadfc5ce19229cbc2" title="This macro may be used to delete all elements of the array before emptying it.">WX_CLEAR_ARRAY()</a> macro for this. <a href="#a61cc6bbeef22f43d9604d00d0ec8f383"></a><br/></td></tr>
<tr class="separator:a61cc6bbeef22f43d9604d00d0ec8f383"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a5d923c5438b43960e0c26c33149b04f3"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a5d923c5438b43960e0c26c33149b04f3">~wxSortedArray</a> ()</td></tr>
<tr class="memdesc:a5d923c5438b43960e0c26c33149b04f3"><td class="mdescLeft"> </td><td class="mdescRight">This destructor does not delete all the items owned by the array, you may use the <a class="el" href="dynarray_8h.html#a2057e24dceef760fadfc5ce19229cbc2" title="This macro may be used to delete all elements of the array before emptying it.">WX_CLEAR_ARRAY()</a> macro for this. <a href="#a5d923c5438b43960e0c26c33149b04f3"></a><br/></td></tr>
<tr class="separator:a5d923c5438b43960e0c26c33149b04f3"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aebb57204007527fe96011b2f16c9dacf"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#aebb57204007527fe96011b2f16c9dacf">~wxObjArray</a> ()</td></tr>
<tr class="memdesc:aebb57204007527fe96011b2f16c9dacf"><td class="mdescLeft"> </td><td class="mdescRight">This destructor deletes all the items owned by the array. <a href="#aebb57204007527fe96011b2f16c9dacf"></a><br/></td></tr>
<tr class="separator:aebb57204007527fe96011b2f16c9dacf"><td class="memSeparator" colspan="2"> </td></tr>
<tr><td colspan="2"><div class="groupHeader">Memory Management</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>Automatic array memory management is quite trivial: the array starts by preallocating some minimal amount of memory (defined by <code>WX_ARRAY_DEFAULT_INITIAL_SIZE</code>) and when further new items exhaust already allocated memory it reallocates it adding 50% of the currently allocated amount, but no more than some maximal number which is defined by the <code>ARRAY_MAXSIZE_INCREMENT</code> constant.</p>
<p>Of course, this may lead to some memory being wasted (<code>ARRAY_MAXSIZE_INCREMENT</code> in the worst case, i.e. 4Kb in the current implementation), so the <a class="el" href="classwx_array_3_01_t_01_4.html#a6184a5915ad4878c39282be949f2e20b" title="Frees all memory unused by the array.">Shrink()</a> function is provided to deallocate the extra memory. The <a class="el" href="classwx_array_3_01_t_01_4.html#a001d4f3d973ed1f9334b83b75e52c277" title="Preallocates memory for a given number of array elements.">Alloc()</a> function can also be quite useful if you know in advance how many items you are going to put in the array and will prevent the array code from reallocating the memory more times than needed. </p>
</div></td></tr>
<tr class="memitem:a001d4f3d973ed1f9334b83b75e52c277"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a001d4f3d973ed1f9334b83b75e52c277">Alloc</a> (size_t count)</td></tr>
<tr class="memdesc:a001d4f3d973ed1f9334b83b75e52c277"><td class="mdescLeft"> </td><td class="mdescRight">Preallocates memory for a given number of array elements. <a href="#a001d4f3d973ed1f9334b83b75e52c277"></a><br/></td></tr>
<tr class="separator:a001d4f3d973ed1f9334b83b75e52c277"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a6184a5915ad4878c39282be949f2e20b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a6184a5915ad4878c39282be949f2e20b">Shrink</a> ()</td></tr>
<tr class="memdesc:a6184a5915ad4878c39282be949f2e20b"><td class="mdescLeft"> </td><td class="mdescRight">Frees all memory unused by the array. <a href="#a6184a5915ad4878c39282be949f2e20b"></a><br/></td></tr>
<tr class="separator:a6184a5915ad4878c39282be949f2e20b"><td class="memSeparator" colspan="2"> </td></tr>
<tr><td colspan="2"><div class="groupHeader">Number of Elements and Simple Item Access</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>Functions in this section return the total number of array elements and allow to retrieve them - possibly using just the C array indexing [] operator which does exactly the same as the <a class="el" href="classwx_array_3_01_t_01_4.html#ae496576cb097636aa2770573f70b67d4" title="Returns the item at the given position in the array.">Item()</a> method. </p>
</div></td></tr>
<tr class="memitem:a526112bb0d7a2ad37d7d432272060ef8"><td class="memItemLeft" align="right" valign="top">size_t </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a526112bb0d7a2ad37d7d432272060ef8">GetCount</a> () const </td></tr>
<tr class="memdesc:a526112bb0d7a2ad37d7d432272060ef8"><td class="mdescLeft"> </td><td class="mdescRight">Return the number of items in the array. <a href="#a526112bb0d7a2ad37d7d432272060ef8"></a><br/></td></tr>
<tr class="separator:a526112bb0d7a2ad37d7d432272060ef8"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a59050981bf25e5b6962fb9fba7ed6c47"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a59050981bf25e5b6962fb9fba7ed6c47">IsEmpty</a> () const </td></tr>
<tr class="memdesc:a59050981bf25e5b6962fb9fba7ed6c47"><td class="mdescLeft"> </td><td class="mdescRight">Returns <span class="literal">true</span> if the array is empty, <span class="literal">false</span> otherwise. <a href="#a59050981bf25e5b6962fb9fba7ed6c47"></a><br/></td></tr>
<tr class="separator:a59050981bf25e5b6962fb9fba7ed6c47"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ae496576cb097636aa2770573f70b67d4"><td class="memItemLeft" align="right" valign="top">T & </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#ae496576cb097636aa2770573f70b67d4">Item</a> (size_t index) const </td></tr>
<tr class="memdesc:ae496576cb097636aa2770573f70b67d4"><td class="mdescLeft"> </td><td class="mdescRight">Returns the item at the given position in the array. <a href="#ae496576cb097636aa2770573f70b67d4"></a><br/></td></tr>
<tr class="separator:ae496576cb097636aa2770573f70b67d4"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ab9b5e30133d9eb6af0c9675c2b99fc8c"><td class="memItemLeft" align="right" valign="top">T & </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#ab9b5e30133d9eb6af0c9675c2b99fc8c">Last</a> () const </td></tr>
<tr class="memdesc:ab9b5e30133d9eb6af0c9675c2b99fc8c"><td class="mdescLeft"> </td><td class="mdescRight">Returns the last element in the array, i.e. is the same as calling "Item(GetCount() - 1)". <a href="#ab9b5e30133d9eb6af0c9675c2b99fc8c"></a><br/></td></tr>
<tr class="separator:ab9b5e30133d9eb6af0c9675c2b99fc8c"><td class="memSeparator" colspan="2"> </td></tr>
<tr><td colspan="2"><div class="groupHeader">Adding Items</div></td></tr>
<tr class="memitem:a0fd8856be5662cb7f07894cf9a318dda"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a0fd8856be5662cb7f07894cf9a318dda">Add</a> (T item, size_t copies=1)</td></tr>
<tr class="memdesc:a0fd8856be5662cb7f07894cf9a318dda"><td class="mdescLeft"> </td><td class="mdescRight">Appends the given number of <em>copies</em> of the <em>item</em> to the array consisting of the elements of type <code>T</code>. <a href="#a0fd8856be5662cb7f07894cf9a318dda"></a><br/></td></tr>
<tr class="separator:a0fd8856be5662cb7f07894cf9a318dda"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a899c54d4193671d14bd3fc8934e83ac0"><td class="memItemLeft" align="right" valign="top">size_t </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a899c54d4193671d14bd3fc8934e83ac0">Add</a> (T item)</td></tr>
<tr class="memdesc:a899c54d4193671d14bd3fc8934e83ac0"><td class="mdescLeft"> </td><td class="mdescRight">Appends the <em>item</em> to the array consisting of the elements of type <code>T</code>. <a href="#a899c54d4193671d14bd3fc8934e83ac0"></a><br/></td></tr>
<tr class="separator:a899c54d4193671d14bd3fc8934e83ac0"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:af6a00260542085cafc38d04ebd34c034"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#af6a00260542085cafc38d04ebd34c034">Add</a> (T *item)</td></tr>
<tr class="memdesc:af6a00260542085cafc38d04ebd34c034"><td class="mdescLeft"> </td><td class="mdescRight">Appends the <em>item</em> to the array consisting of the elements of type <code>T</code>. <a href="#af6a00260542085cafc38d04ebd34c034"></a><br/></td></tr>
<tr class="separator:af6a00260542085cafc38d04ebd34c034"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a22a22c4f4cf3c9e9883dba5699abaf63"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a22a22c4f4cf3c9e9883dba5699abaf63">Add</a> (T &item, size_t copies=1)</td></tr>
<tr class="memdesc:a22a22c4f4cf3c9e9883dba5699abaf63"><td class="mdescLeft"> </td><td class="mdescRight">Appends the given number of <em>copies</em> of the <em>item</em> to the array consisting of the elements of type <code>T</code>. <a href="#a22a22c4f4cf3c9e9883dba5699abaf63"></a><br/></td></tr>
<tr class="separator:a22a22c4f4cf3c9e9883dba5699abaf63"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a823040226372bac18bca3bd21b61621e"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a823040226372bac18bca3bd21b61621e">AddAt</a> (T item, size_t index)</td></tr>
<tr class="memdesc:a823040226372bac18bca3bd21b61621e"><td class="mdescLeft"> </td><td class="mdescRight">Inserts the given <em>item</em> into the array in the specified <em>index</em> position. <a href="#a823040226372bac18bca3bd21b61621e"></a><br/></td></tr>
<tr class="separator:a823040226372bac18bca3bd21b61621e"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ae3125ce69e5b1d6a7ec06b0d4bddad63"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#ae3125ce69e5b1d6a7ec06b0d4bddad63">Insert</a> (T item, size_t n, size_t copies=1)</td></tr>
<tr class="memdesc:ae3125ce69e5b1d6a7ec06b0d4bddad63"><td class="mdescLeft"> </td><td class="mdescRight">Insert the given number of <em>copies</em> of the <em>item</em> into the array before the existing item <em>n</em> - thus, <em>Insert(something, 0u)</em> will insert an item in such way that it will become the first array element. <a href="#ae3125ce69e5b1d6a7ec06b0d4bddad63"></a><br/></td></tr>
<tr class="separator:ae3125ce69e5b1d6a7ec06b0d4bddad63"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ac3eadfa94a64c21a079c8ad9e6e37693"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#ac3eadfa94a64c21a079c8ad9e6e37693">Insert</a> (T *item, size_t n)</td></tr>
<tr class="memdesc:ac3eadfa94a64c21a079c8ad9e6e37693"><td class="mdescLeft"> </td><td class="mdescRight">Insert the <em>item</em> into the array before the existing item <em>n</em> - thus, <em>Insert(something, 0u)</em> will insert an item in such way that it will become the first array element. <a href="#ac3eadfa94a64c21a079c8ad9e6e37693"></a><br/></td></tr>
<tr class="separator:ac3eadfa94a64c21a079c8ad9e6e37693"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aa4f2ca3de52cdf37e2a7d0b88c27541b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#aa4f2ca3de52cdf37e2a7d0b88c27541b">Insert</a> (T &item, size_t n, size_t copies=1)</td></tr>
<tr class="memdesc:aa4f2ca3de52cdf37e2a7d0b88c27541b"><td class="mdescLeft"> </td><td class="mdescRight">Insert the given number of <em>copies</em> of the <em>item</em> into the array before the existing item <em>n</em> - thus, <em>Insert(something, 0u)</em> will insert an item in such way that it will become the first array element. <a href="#aa4f2ca3de52cdf37e2a7d0b88c27541b"></a><br/></td></tr>
<tr class="separator:aa4f2ca3de52cdf37e2a7d0b88c27541b"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:adfddd024c1385af0f089ed37b96defe0"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#adfddd024c1385af0f089ed37b96defe0">SetCount</a> (size_t count, T defval=T(0))</td></tr>
<tr class="memdesc:adfddd024c1385af0f089ed37b96defe0"><td class="mdescLeft"> </td><td class="mdescRight">This function ensures that the number of array elements is at least <em>count</em>. <a href="#adfddd024c1385af0f089ed37b96defe0"></a><br/></td></tr>
<tr class="separator:adfddd024c1385af0f089ed37b96defe0"><td class="memSeparator" colspan="2"> </td></tr>
<tr><td colspan="2"><div class="groupHeader">Removing Items</div></td></tr>
<tr class="memitem:a7c8302670949e819c4b442aba9e258e6"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a7c8302670949e819c4b442aba9e258e6">Clear</a> ()</td></tr>
<tr class="memdesc:a7c8302670949e819c4b442aba9e258e6"><td class="mdescLeft"> </td><td class="mdescRight">This function does the same as <a class="el" href="classwx_array_3_01_t_01_4.html#adf1797565eeba15d33b1cb8becb1bfe9" title="Empties the array.">Empty()</a> and additionally frees the memory allocated to the array. <a href="#a7c8302670949e819c4b442aba9e258e6"></a><br/></td></tr>
<tr class="separator:a7c8302670949e819c4b442aba9e258e6"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a4e49e0385927180ddc2332ff85724a3e"><td class="memItemLeft" align="right" valign="top">T * </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a4e49e0385927180ddc2332ff85724a3e">Detach</a> (size_t index)</td></tr>
<tr class="memdesc:a4e49e0385927180ddc2332ff85724a3e"><td class="mdescLeft"> </td><td class="mdescRight">Removes the element from the array, but unlike <a class="el" href="classwx_array_3_01_t_01_4.html#a917cf490b105c84bb06deb2a9d2f104f" title="Removes an element from the array by value: the first item of the array equal to item is removed...">Remove()</a>, it doesn't delete it. <a href="#a4e49e0385927180ddc2332ff85724a3e"></a><br/></td></tr>
<tr class="separator:a4e49e0385927180ddc2332ff85724a3e"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:adf1797565eeba15d33b1cb8becb1bfe9"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#adf1797565eeba15d33b1cb8becb1bfe9">Empty</a> ()</td></tr>
<tr class="memdesc:adf1797565eeba15d33b1cb8becb1bfe9"><td class="mdescLeft"> </td><td class="mdescRight">Empties the array. <a href="#adf1797565eeba15d33b1cb8becb1bfe9"></a><br/></td></tr>
<tr class="separator:adf1797565eeba15d33b1cb8becb1bfe9"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a917cf490b105c84bb06deb2a9d2f104f"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a917cf490b105c84bb06deb2a9d2f104f">Remove</a> (T item)</td></tr>
<tr class="memdesc:a917cf490b105c84bb06deb2a9d2f104f"><td class="mdescLeft"> </td><td class="mdescRight">Removes an element from the array by value: the first item of the array equal to <em>item</em> is removed, an assert failure will result from an attempt to remove an item which doesn't exist in the array. <a href="#a917cf490b105c84bb06deb2a9d2f104f"></a><br/></td></tr>
<tr class="separator:a917cf490b105c84bb06deb2a9d2f104f"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a7f5d1a313c7999bd2110157fdacaa026"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a7f5d1a313c7999bd2110157fdacaa026">RemoveAt</a> (size_t index, size_t count=1)</td></tr>
<tr class="memdesc:a7f5d1a313c7999bd2110157fdacaa026"><td class="mdescLeft"> </td><td class="mdescRight">Removes <em>count</em> elements starting at <em>index</em> from the array. <a href="#a7f5d1a313c7999bd2110157fdacaa026"></a><br/></td></tr>
<tr class="separator:a7f5d1a313c7999bd2110157fdacaa026"><td class="memSeparator" colspan="2"> </td></tr>
<tr><td colspan="2"><div class="groupHeader">Searching and Sorting</div></td></tr>
<tr class="memitem:a9627dd7d9eba85d25a4aa1b666ab9a9c"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a9627dd7d9eba85d25a4aa1b666ab9a9c">Index</a> (T &item, bool searchFromEnd=false) const </td></tr>
<tr class="memdesc:a9627dd7d9eba85d25a4aa1b666ab9a9c"><td class="mdescLeft"> </td><td class="mdescRight">This version of <a class="el" href="classwx_array_3_01_t_01_4.html#a9627dd7d9eba85d25a4aa1b666ab9a9c" title="This version of Index() is for wxArray and wxObjArray only.">Index()</a> is for wxArray and wxObjArray only. <a href="#a9627dd7d9eba85d25a4aa1b666ab9a9c"></a><br/></td></tr>
<tr class="separator:a9627dd7d9eba85d25a4aa1b666ab9a9c"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:abc08a79fe800638f315b35cb34272d7a"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#abc08a79fe800638f315b35cb34272d7a">Index</a> (T &item) const </td></tr>
<tr class="memdesc:abc08a79fe800638f315b35cb34272d7a"><td class="mdescLeft"> </td><td class="mdescRight">This version of <a class="el" href="classwx_array_3_01_t_01_4.html#a9627dd7d9eba85d25a4aa1b666ab9a9c" title="This version of Index() is for wxArray and wxObjArray only.">Index()</a> is for wxSortedArray only. <a href="#abc08a79fe800638f315b35cb34272d7a"></a><br/></td></tr>
<tr class="separator:abc08a79fe800638f315b35cb34272d7a"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a6f9fbb4563437d24283f105a81321416"><td class="memItemLeft" align="right" valign="top">size_t </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#a6f9fbb4563437d24283f105a81321416">IndexForInsert</a> (T item) const </td></tr>
<tr class="memdesc:a6f9fbb4563437d24283f105a81321416"><td class="mdescLeft"> </td><td class="mdescRight">Search for a place to insert <em>item</em> into the sorted array (binary search). <a href="#a6f9fbb4563437d24283f105a81321416"></a><br/></td></tr>
<tr class="separator:a6f9fbb4563437d24283f105a81321416"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ae45b012bef8ed8980310b17edd37a9c7"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_array_3_01_t_01_4.html#ae45b012bef8ed8980310b17edd37a9c7">Sort</a> (CMPFUNC< T > compareFunction)</td></tr>
<tr class="memdesc:ae45b012bef8ed8980310b17edd37a9c7"><td class="mdescLeft"> </td><td class="mdescRight">The notation <code>"CMPFUNCT<T>"</code> should be read as if we had the following declaration: <a href="#ae45b012bef8ed8980310b17edd37a9c7"></a><br/></td></tr>
<tr class="separator:ae45b012bef8ed8980310b17edd37a9c7"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<h2 class="groupheader">Constructor & Destructor Documentation</h2>
<a class="anchor" id="a714c1ed4b8be1a8e7073ebe8ae387303"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">wxArray< T >::wxArray </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Default constructor. </p>
</div>
</div>
<a class="anchor" id="ae6ce544f41797c2bca97507beca57b6c"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">wxArray< T >::wxArray </td>
<td>(</td>
<td class="paramtype">const wxArray< T > & </td>
<td class="paramname"><em>array</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Performs a shallow array copy (i.e. doesn't copy the objects pointed to even if the source array contains the items of pointer type). </p>
</div>
</div>
<a class="anchor" id="a61cc6bbeef22f43d9604d00d0ec8f383"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::~<a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>This destructor does not delete all the items owned by the array, you may use the <a class="el" href="dynarray_8h.html#a2057e24dceef760fadfc5ce19229cbc2" title="This macro may be used to delete all elements of the array before emptying it.">WX_CLEAR_ARRAY()</a> macro for this. </p>
</div>
</div>
<a class="anchor" id="a5d923c5438b43960e0c26c33149b04f3"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::~<a class="el" href="classwx_array_3_01_t_01_4.html#a7fcfbd2fa53fe042ea385f4e254729da">wxSortedArray</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>This destructor does not delete all the items owned by the array, you may use the <a class="el" href="dynarray_8h.html#a2057e24dceef760fadfc5ce19229cbc2" title="This macro may be used to delete all elements of the array before emptying it.">WX_CLEAR_ARRAY()</a> macro for this. </p>
</div>
</div>
<a class="anchor" id="aebb57204007527fe96011b2f16c9dacf"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::~<a class="el" href="classwx_array_3_01_t_01_4.html#adff3fffdc4b2a51cb0ad4606114714ab">wxObjArray</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>This destructor deletes all the items owned by the array. </p>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a0fd8856be5662cb7f07894cf9a318dda"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Add </td>
<td>(</td>
<td class="paramtype">T </td>
<td class="paramname"><em>item</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"><em>copies</em> = <code>1</code> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the given number of <em>copies</em> of the <em>item</em> to the array consisting of the elements of type <code>T</code>. </p>
<p>This version is used with wxArray.</p>
<p>You may also use <a class="el" href="dynarray_8h.html#a7631438cf6263e77795c6905e0949b58" title="This macro may be used to append all elements of the wxArray_arrayToBeAppended array to the wxArray_a...">WX_APPEND_ARRAY()</a> macro to append all elements of one array to another one but it is more efficient to use the <em>copies</em> parameter and modify the elements in place later if you plan to append a lot of items. </p>
</div>
</div>
<a class="anchor" id="a899c54d4193671d14bd3fc8934e83ac0"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">size_t <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Add </td>
<td>(</td>
<td class="paramtype">T </td>
<td class="paramname"><em>item</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the <em>item</em> to the array consisting of the elements of type <code>T</code>. </p>
<p>This version is used with wxSortedArray, returning the index where <em>item</em> is stored. </p>
</div>
</div>
<a class="anchor" id="af6a00260542085cafc38d04ebd34c034"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Add </td>
<td>(</td>
<td class="paramtype">T * </td>
<td class="paramname"><em>item</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the <em>item</em> to the array consisting of the elements of type <code>T</code>. </p>
<p>This version is used with wxObjArray. The array will take ownership of the <em>item</em>, deleting it when the item is deleted from the array. Note that you cannot append more than one pointer as reusing it would lead to deleting it twice (or more) resulting in a crash.</p>
<p>You may also use <a class="el" href="dynarray_8h.html#a7631438cf6263e77795c6905e0949b58" title="This macro may be used to append all elements of the wxArray_arrayToBeAppended array to the wxArray_a...">WX_APPEND_ARRAY()</a> macro to append all elements of one array to another one but it is more efficient to use the <em>copies</em> parameter and modify the elements in place later if you plan to append a lot of items. </p>
</div>
</div>
<a class="anchor" id="a22a22c4f4cf3c9e9883dba5699abaf63"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Add </td>
<td>(</td>
<td class="paramtype">T & </td>
<td class="paramname"><em>item</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"><em>copies</em> = <code>1</code> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the given number of <em>copies</em> of the <em>item</em> to the array consisting of the elements of type <code>T</code>. </p>
<p>This version is used with wxObjArray. The array will make a copy of the item and will not take ownership of the original item.</p>
<p>You may also use <a class="el" href="dynarray_8h.html#a7631438cf6263e77795c6905e0949b58" title="This macro may be used to append all elements of the wxArray_arrayToBeAppended array to the wxArray_a...">WX_APPEND_ARRAY()</a> macro to append all elements of one array to another one but it is more efficient to use the <em>copies</em> parameter and modify the elements in place later if you plan to append a lot of items. </p>
</div>
</div>
<a class="anchor" id="a823040226372bac18bca3bd21b61621e"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::AddAt </td>
<td>(</td>
<td class="paramtype">T </td>
<td class="paramname"><em>item</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"><em>index</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Inserts the given <em>item</em> into the array in the specified <em>index</em> position. </p>
<p>Be aware that you will set out the order of the array if you give a wrong position.</p>
<p>This function is useful in conjunction with <a class="el" href="classwx_array_3_01_t_01_4.html#a6f9fbb4563437d24283f105a81321416" title="Search for a place to insert item into the sorted array (binary search).">IndexForInsert()</a> for a common operation of "insert only if not found". </p>
</div>
</div>
<a class="anchor" id="a001d4f3d973ed1f9334b83b75e52c277"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Alloc </td>
<td>(</td>
<td class="paramtype">size_t </td>
<td class="paramname"><em>count</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Preallocates memory for a given number of array elements. </p>
<p>It is worth calling when the number of items which are going to be added to the array is known in advance because it will save unneeded memory reallocation. If the array already has enough memory for the given number of items, nothing happens. In any case, the existing contents of the array is not modified. </p>
</div>
</div>
<a class="anchor" id="a7c8302670949e819c4b442aba9e258e6"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Clear </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>This function does the same as <a class="el" href="classwx_array_3_01_t_01_4.html#adf1797565eeba15d33b1cb8becb1bfe9" title="Empties the array.">Empty()</a> and additionally frees the memory allocated to the array. </p>
</div>
</div>
<a class="anchor" id="a4e49e0385927180ddc2332ff85724a3e"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">T* <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Detach </td>
<td>(</td>
<td class="paramtype">size_t </td>
<td class="paramname"><em>index</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Removes the element from the array, but unlike <a class="el" href="classwx_array_3_01_t_01_4.html#a917cf490b105c84bb06deb2a9d2f104f" title="Removes an element from the array by value: the first item of the array equal to item is removed...">Remove()</a>, it doesn't delete it. </p>
<p>The function returns the pointer to the removed element. </p>
</div>
</div>
<a class="anchor" id="adf1797565eeba15d33b1cb8becb1bfe9"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Empty </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Empties the array. </p>
<p>For wxObjArray classes, this destroys all of the array elements. For wxArray and wxSortedArray this does nothing except marking the array of being empty - this function does not free the allocated memory, use <a class="el" href="classwx_array_3_01_t_01_4.html#a7c8302670949e819c4b442aba9e258e6" title="This function does the same as Empty() and additionally frees the memory allocated to the array...">Clear()</a> for this. </p>
</div>
</div>
<a class="anchor" id="a526112bb0d7a2ad37d7d432272060ef8"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">size_t <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::GetCount </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</div><div class="memdoc">
<p>Return the number of items in the array. </p>
</div>
</div>
<a class="anchor" id="a9627dd7d9eba85d25a4aa1b666ab9a9c"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">int <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Index </td>
<td>(</td>
<td class="paramtype">T & </td>
<td class="paramname"><em>item</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">bool </td>
<td class="paramname"><em>searchFromEnd</em> = <code>false</code> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td> const</td>
</tr>
</table>
</div><div class="memdoc">
<p>This version of <a class="el" href="classwx_array_3_01_t_01_4.html#a9627dd7d9eba85d25a4aa1b666ab9a9c" title="This version of Index() is for wxArray and wxObjArray only.">Index()</a> is for wxArray and wxObjArray only. </p>
<p>Searches the element in the array, starting from either beginning or the end depending on the value of <em>searchFromEnd</em> parameter. <code>wxNOT_FOUND</code> is returned if the element is not found, otherwise the index of the element is returned.</p>
<dl class="section note"><dt>Note</dt><dd>Even for wxObjArray classes, the operator "==" of the elements in the array is <b>not</b> used by this function. It searches exactly the given element in the array and so will only succeed if this element had been previously added to the array, but fail even if another, identical, element is in the array. </dd></dl>
</div>
</div>
<a class="anchor" id="abc08a79fe800638f315b35cb34272d7a"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">int <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Index </td>
<td>(</td>
<td class="paramtype">T & </td>
<td class="paramname"><em>item</em></td><td>)</td>
<td> const</td>
</tr>
</table>
</div><div class="memdoc">
<p>This version of <a class="el" href="classwx_array_3_01_t_01_4.html#a9627dd7d9eba85d25a4aa1b666ab9a9c" title="This version of Index() is for wxArray and wxObjArray only.">Index()</a> is for wxSortedArray only. </p>
<p>Searches for the element in the array, using binary search.</p>
<p><code>wxNOT_FOUND</code> is returned if the element is not found, otherwise the index of the element is returned. </p>
</div>
</div>
<a class="anchor" id="a6f9fbb4563437d24283f105a81321416"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">size_t <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::IndexForInsert </td>
<td>(</td>
<td class="paramtype">T </td>
<td class="paramname"><em>item</em></td><td>)</td>
<td> const</td>
</tr>
</table>
</div><div class="memdoc">
<p>Search for a place to insert <em>item</em> into the sorted array (binary search). </p>
<p>The index returned is just before the first existing item that is greater or equal (according to the compare function) to the given <em>item</em>.</p>
<p>You have to do extra work to know if the <em>item</em> already exists in array.</p>
<p>This function is useful in conjunction with <a class="el" href="classwx_array_3_01_t_01_4.html#a823040226372bac18bca3bd21b61621e" title="Inserts the given item into the array in the specified index position.">AddAt()</a> for a common operation of "insert only if not found". </p>
</div>
</div>
<a class="anchor" id="ae3125ce69e5b1d6a7ec06b0d4bddad63"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Insert </td>
<td>(</td>
<td class="paramtype">T </td>
<td class="paramname"><em>item</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"><em>n</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"><em>copies</em> = <code>1</code> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Insert the given number of <em>copies</em> of the <em>item</em> into the array before the existing item <em>n</em> - thus, <em>Insert(something, 0u)</em> will insert an item in such way that it will become the first array element. </p>
<p>wxSortedArray doesn't have this function because inserting in wrong place would break its sorted condition.</p>
<p>Please see <a class="el" href="classwx_array_3_01_t_01_4.html#a0fd8856be5662cb7f07894cf9a318dda" title="Appends the given number of copies of the item to the array consisting of the elements of type T...">Add()</a> for an explanation of the differences between the overloaded versions of this function. </p>
</div>
</div>
<a class="anchor" id="ac3eadfa94a64c21a079c8ad9e6e37693"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Insert </td>
<td>(</td>
<td class="paramtype">T * </td>
<td class="paramname"><em>item</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"><em>n</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Insert the <em>item</em> into the array before the existing item <em>n</em> - thus, <em>Insert(something, 0u)</em> will insert an item in such way that it will become the first array element. </p>
<p>wxSortedArray doesn't have this function because inserting in wrong place would break its sorted condition.</p>
<p>Please see <a class="el" href="classwx_array_3_01_t_01_4.html#a0fd8856be5662cb7f07894cf9a318dda" title="Appends the given number of copies of the item to the array consisting of the elements of type T...">Add()</a> for an explanation of the differences between the overloaded versions of this function. </p>
</div>
</div>
<a class="anchor" id="aa4f2ca3de52cdf37e2a7d0b88c27541b"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Insert </td>
<td>(</td>
<td class="paramtype">T & </td>
<td class="paramname"><em>item</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"><em>n</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"><em>copies</em> = <code>1</code> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Insert the given number of <em>copies</em> of the <em>item</em> into the array before the existing item <em>n</em> - thus, <em>Insert(something, 0u)</em> will insert an item in such way that it will become the first array element. </p>
<p>wxSortedArray doesn't have this function because inserting in wrong place would break its sorted condition.</p>
<p>Please see <a class="el" href="classwx_array_3_01_t_01_4.html#a0fd8856be5662cb7f07894cf9a318dda" title="Appends the given number of copies of the item to the array consisting of the elements of type T...">Add()</a> for an explanation of the differences between the overloaded versions of this function. </p>
</div>
</div>
<a class="anchor" id="a59050981bf25e5b6962fb9fba7ed6c47"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">bool <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::IsEmpty </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns <span class="literal">true</span> if the array is empty, <span class="literal">false</span> otherwise. </p>
</div>
</div>
<a class="anchor" id="ae496576cb097636aa2770573f70b67d4"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">T& <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Item </td>
<td>(</td>
<td class="paramtype">size_t </td>
<td class="paramname"><em>index</em></td><td>)</td>
<td> const</td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns the item at the given position in the array. </p>
<p>If <em>index</em> is out of bounds, an assert failure is raised in the debug builds but nothing special is done in the release build.</p>
<p>The returned value is of type "reference to the array element type" for all of the array classes. </p>
</div>
</div>
<a class="anchor" id="ab9b5e30133d9eb6af0c9675c2b99fc8c"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">T& <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Last </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns the last element in the array, i.e. is the same as calling "Item(GetCount() - 1)". </p>
<p>An assert failure is raised in the debug mode if the array is empty.</p>
<p>The returned value is of type "reference to the array element type" for all of the array classes. </p>
</div>
</div>
<a class="anchor" id="a713b8bad4b168eeaba235aad4b4ac562"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>& <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::operator= </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T > & </td>
<td class="paramname"><em>array</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Performs a shallow array copy (i.e. doesn't copy the objects pointed to even if the source array contains the items of pointer type). </p>
</div>
</div>
<a class="anchor" id="a3480573120c8a425ca8aaee72462c469"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classwx_array_3_01_t_01_4.html#a7fcfbd2fa53fe042ea385f4e254729da">wxSortedArray</a>& <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::operator= </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classwx_array_3_01_t_01_4.html#a7fcfbd2fa53fe042ea385f4e254729da">wxSortedArray</a> & </td>
<td class="paramname"><em>array</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Performs a shallow array copy (i.e. doesn't copy the objects pointed to even if the source array contains the items of pointer type). </p>
</div>
</div>
<a class="anchor" id="afac88aa2fde976cb6e131369296843d2"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classwx_array_3_01_t_01_4.html#adff3fffdc4b2a51cb0ad4606114714ab">wxObjArray</a>& <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::operator= </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="classwx_array_3_01_t_01_4.html#adff3fffdc4b2a51cb0ad4606114714ab">wxObjArray</a> & </td>
<td class="paramname"><em>array</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Performs a deep copy (i.e. the array element are copied too). </p>
</div>
</div>
<a class="anchor" id="a917cf490b105c84bb06deb2a9d2f104f"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Remove </td>
<td>(</td>
<td class="paramtype">T </td>
<td class="paramname"><em>item</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Removes an element from the array by value: the first item of the array equal to <em>item</em> is removed, an assert failure will result from an attempt to remove an item which doesn't exist in the array. </p>
<p>When an element is removed from wxObjArray it is deleted by the array - use <a class="el" href="classwx_array_3_01_t_01_4.html#a4e49e0385927180ddc2332ff85724a3e" title="Removes the element from the array, but unlike Remove(), it doesn't delete it.">Detach()</a> if you don't want this to happen. On the other hand, when an object is removed from a wxArray nothing happens - you should delete it manually if required:</p>
<div class="fragment"><div class="line">T *item = array[n];</div>
<div class="line">array.Remove(item);</div>
<div class="line"><span class="keyword">delete</span> item;</div>
</div><!-- fragment --><p>See also <a class="el" href="dynarray_8h.html#a2057e24dceef760fadfc5ce19229cbc2" title="This macro may be used to delete all elements of the array before emptying it.">WX_CLEAR_ARRAY()</a> macro which deletes all elements of a wxArray (supposed to contain pointers).</p>
<p>Notice that for sorted arrays this method uses binary search to find the item so it doesn't necessarily remove the first matching item, but the first one found by the binary search.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classwx_array_3_01_t_01_4.html#a7f5d1a313c7999bd2110157fdacaa026" title="Removes count elements starting at index from the array.">RemoveAt()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="a7f5d1a313c7999bd2110157fdacaa026"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::RemoveAt </td>
<td>(</td>
<td class="paramtype">size_t </td>
<td class="paramname"><em>index</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"><em>count</em> = <code>1</code> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Removes <em>count</em> elements starting at <em>index</em> from the array. </p>
<p>When an element is removed from wxObjArray it is deleted by the array - use <a class="el" href="classwx_array_3_01_t_01_4.html#a4e49e0385927180ddc2332ff85724a3e" title="Removes the element from the array, but unlike Remove(), it doesn't delete it.">Detach()</a> if you don't want this to happen. On the other hand, when an object is removed from a wxArray nothing happens - you should delete it manually if required:</p>
<div class="fragment"><div class="line">T *item = array[n];</div>
<div class="line"><span class="keyword">delete</span> item;</div>
<div class="line">array.RemoveAt(n);</div>
</div><!-- fragment --><p>See also <a class="el" href="dynarray_8h.html#a2057e24dceef760fadfc5ce19229cbc2" title="This macro may be used to delete all elements of the array before emptying it.">WX_CLEAR_ARRAY()</a> macro which deletes all elements of a wxArray (supposed to contain pointers). </p>
</div>
</div>
<a class="anchor" id="adfddd024c1385af0f089ed37b96defe0"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::SetCount </td>
<td>(</td>
<td class="paramtype">size_t </td>
<td class="paramname"><em>count</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">T </td>
<td class="paramname"><em>defval</em> = <code>T(0)</code> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>This function ensures that the number of array elements is at least <em>count</em>. </p>
<p>If the array has already <em>count</em> or more items, nothing is done. Otherwise, <em>count</em> - <a class="el" href="classwx_array_3_01_t_01_4.html#a526112bb0d7a2ad37d7d432272060ef8" title="Return the number of items in the array.">GetCount()</a> elements are added and initialized to the value <em>defval</em>.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classwx_array_3_01_t_01_4.html#a526112bb0d7a2ad37d7d432272060ef8" title="Return the number of items in the array.">GetCount()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="a6184a5915ad4878c39282be949f2e20b"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Shrink </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Frees all memory unused by the array. </p>
<p>If the program knows that no new items will be added to the array it may call <a class="el" href="classwx_array_3_01_t_01_4.html#a6184a5915ad4878c39282be949f2e20b" title="Frees all memory unused by the array.">Shrink()</a> to reduce its memory usage. However, if a new item is added to the array, some extra memory will be allocated again. </p>
</div>
</div>
<a class="anchor" id="ae45b012bef8ed8980310b17edd37a9c7"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::Sort </td>
<td>(</td>
<td class="paramtype">CMPFUNC< T > </td>
<td class="paramname"><em>compareFunction</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>The notation <code>"CMPFUNCT<T>"</code> should be read as if we had the following declaration: </p>
<div class="fragment"><div class="line"><span class="keyword">template</span> <span class="keywordtype">int</span> CMPFUNC(T *first, T *second);</div>
</div><!-- fragment --><p>Where <em>T</em> is the type of the array elements. I.e. it is a function returning <em>int</em> which is passed two arguments of type <em>T*</em>.</p>
<p>Sorts the array using the specified compare function: this function should return a negative, zero or positive value according to whether the first element passed to it is less than, equal to or greater than the second one.</p>
<p>wxSortedArray doesn't have this function because it is always sorted. </p>
</div>
</div>
<a class="anchor" id="adff3fffdc4b2a51cb0ad4606114714ab"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::wxObjArray </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Default constructor initializes an empty array object. </p>
</div>
</div>
<a class="anchor" id="a7379d427e1cf74eba4cdc27f44c7c682"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::wxObjArray </td>
<td>(</td>
<td class="paramtype">const wxObjArray & </td>
<td class="paramname"><em>array</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Performs a deep copy (i.e. the array element are copied too). </p>
</div>
</div>
<a class="anchor" id="a7fcfbd2fa53fe042ea385f4e254729da"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::wxSortedArray </td>
<td>(</td>
<td class="paramtype">int(*)(T first, T second) </td>
<td class="paramname"><em>compareFunction</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>There is no default constructor for wxSortedArray classes - you must initialize it with a function to use for item comparison. </p>
<p>It is a function which is passed two arguments of type <code>T</code> where <code>T</code> is the array element type and which should return a negative, zero or positive value according to whether the first element passed to it is less than, equal to or greater than the second one. </p>
</div>
</div>
<a class="anchor" id="a27baa04ffabb62aab9357e6c92a4d430"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<typename T > </div>
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classwx_array_3_01_t_01_4.html#a714c1ed4b8be1a8e7073ebe8ae387303">wxArray</a>< T >::wxSortedArray </td>
<td>(</td>
<td class="paramtype">const wxSortedArray & </td>
<td class="paramname"><em>array</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Performs a shallow array copy (i.e. doesn't copy the objects pointed to even if the source array contains the items of pointer type). </p>
</div>
</div>
</div><!-- contents -->
<address class="footer">
<small>
Generated on Thu Nov 27 2014 13:46:43 for wxWidgets by <a href="http://www.doxygen.org/index.html" target="_new">Doxygen</a> 1.8.2
</small>
</address>
<script src="wxwidgets.js" type="text/javascript"></script>
</div><!-- #page_container -->
</body>
</html>
|