Source

cappuccino-docs / cappuccino docs / cappuccino.org / learn / documentation / _c_p_array_8j_source.html

Full commit
  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
<!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">

<!-- Mirrored from cappuccino.org/learn/documentation/_c_p_array_8j_source.html by HTTrack Website Copier/3.x [XR&CO'2006], Mon, 20 Sep 2010 02:19:29 GMT -->
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Cappuccino API: Foundation/CPArray.j Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>Foundation/CPArray.j</h1><a href="_c_p_array_8j.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * CPArray.j</span>
<a name="l00003"></a>00003 <span class="comment"> * Foundation</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> * Created by Francisco Tolmasky.</span>
<a name="l00006"></a>00006 <span class="comment"> * Copyright 2008, 280 North, Inc.</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
<a name="l00009"></a>00009 <span class="comment"> * modify it under the terms of the GNU Lesser General Public</span>
<a name="l00010"></a>00010 <span class="comment"> * License as published by the Free Software Foundation; either</span>
<a name="l00011"></a>00011 <span class="comment"> * version 2.1 of the License, or (at your option) any later version.</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * This library is distributed in the hope that it will be useful,</span>
<a name="l00014"></a>00014 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00015"></a>00015 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
<a name="l00016"></a>00016 <span class="comment"> * Lesser General Public License for more details.</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> * You should have received a copy of the GNU Lesser General Public</span>
<a name="l00019"></a>00019 <span class="comment"> * License along with this library; if not, write to the Free Software</span>
<a name="l00020"></a>00020 <span class="comment"> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA</span>
<a name="l00021"></a>00021 <span class="comment"> */</span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 @<span class="keyword">import</span> <span class="stringliteral">&quot;CPObject.j&quot;</span>
<a name="l00024"></a>00024 @<span class="keyword">import</span> <span class="stringliteral">&quot;CPRange.j&quot;</span>
<a name="l00025"></a>00025 @<span class="keyword">import</span> <span class="stringliteral">&quot;CPEnumerator.j&quot;</span>
<a name="l00026"></a>00026 @<span class="keyword">import</span> <span class="stringliteral">&quot;CPSortDescriptor.j&quot;</span>
<a name="l00027"></a>00027 @<span class="keyword">import</span> <span class="stringliteral">&quot;CPException.j&quot;</span>
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <span class="comment">/* @ignore */</span>
<a name="l00031"></a>00031 <span class="keyword">@implementation </span>_CPArrayEnumerator : <a class="code" href="class_c_p_enumerator.html" title="Defines an interface for enumerators.">CPEnumerator</a>
<a name="l00032"></a>00032 {
<a name="l00033"></a>00033     <a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a> _array;
<a name="l00034"></a>00034     <span class="keywordtype">int</span>     _index;
<a name="l00035"></a>00035 }
<a name="l00036"></a>00036 
<a name="l00037"></a>00037 - (id)initWithArray:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)anArray
<a name="l00038"></a>00038 {
<a name="l00039"></a>00039     <span class="keyword">self</span> = [<span class="keyword">super</span> init];
<a name="l00040"></a>00040     
<a name="l00041"></a>00041     <span class="keywordflow">if</span> (<span class="keyword">self</span>)
<a name="l00042"></a>00042     {
<a name="l00043"></a>00043         _array = anArray;
<a name="l00044"></a>00044         _index = -1;
<a name="l00045"></a>00045     }
<a name="l00046"></a>00046 
<a name="l00047"></a>00047     <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00048"></a>00048 }
<a name="l00049"></a>00049 
<a name="l00050"></a>00050 - (id)nextObject
<a name="l00051"></a>00051 {
<a name="l00052"></a>00052     <span class="keywordflow">if</span> (++_index &gt;= [_array count])
<a name="l00053"></a>00053         <span class="keywordflow">return</span> nil;
<a name="l00054"></a>00054 
<a name="l00055"></a>00055     <span class="keywordflow">return</span> [_array objectAtIndex:_index];
<a name="l00056"></a>00056 }
<a name="l00057"></a>00057 
<a name="l00058"></a>00058 <span class="keyword">@end</span>
<a name="l00059"></a>00059 
<a name="l00060"></a>00060 <span class="comment">/* @ignore */</span>
<a name="l00061"></a>00061 <span class="keyword">@implementation </span>_CPReverseArrayEnumerator : <a class="code" href="class_c_p_enumerator.html" title="Defines an interface for enumerators.">CPEnumerator</a>
<a name="l00062"></a>00062 {
<a name="l00063"></a>00063     <a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a> _array;
<a name="l00064"></a>00064     <span class="keywordtype">int</span>     _index;
<a name="l00065"></a>00065 }
<a name="l00066"></a>00066 
<a name="l00067"></a>00067 - (id)initWithArray:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)anArray
<a name="l00068"></a>00068 {
<a name="l00069"></a>00069     <span class="keyword">self</span> = [<span class="keyword">super</span> init];
<a name="l00070"></a>00070     
<a name="l00071"></a>00071     <span class="keywordflow">if</span> (<span class="keyword">self</span>)
<a name="l00072"></a>00072     {
<a name="l00073"></a>00073         _array = anArray;
<a name="l00074"></a>00074         _index = [_array count];
<a name="l00075"></a>00075     }
<a name="l00076"></a>00076     
<a name="l00077"></a>00077     <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00078"></a>00078 }
<a name="l00079"></a>00079 
<a name="l00080"></a>00080 - (id)nextObject
<a name="l00081"></a>00081 {
<a name="l00082"></a>00082     <span class="keywordflow">if</span> (--_index &lt; 0)
<a name="l00083"></a>00083         <span class="keywordflow">return</span> nil;
<a name="l00084"></a>00084 
<a name="l00085"></a>00085     <span class="keywordflow">return</span> [_array objectAtIndex:_index];
<a name="l00086"></a>00086 }
<a name="l00087"></a>00087 
<a name="l00088"></a>00088 <span class="keyword">@end</span>
<a name="l00089"></a>00089 
<a name="l00101"></a>00101 <span class="keyword">@implementation </span><a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a> : <a class="code" href="class_c_p_object.html" title="The root class from which most classes are subclassed.">CPObject</a>
<a name="l00102"></a>00102 
<a name="l00106"></a>00106 + (id)alloc
<a name="l00107"></a>00107 {
<a name="l00108"></a>00108     <span class="keywordflow">return</span> [];
<a name="l00109"></a>00109 }
<a name="l00110"></a>00110 
<a name="l00114"></a><a class="code" href="class_c_p_array.html#aafeaf98dd280821940da2ec8be05b776">00114</a> + (id)<a class="code" href="class_c_p_array.html#aafeaf98dd280821940da2ec8be05b776">array</a>
<a name="l00115"></a>00115 {
<a name="l00116"></a>00116     <span class="keywordflow">return</span> [[<span class="keyword">self</span> alloc] init];
<a name="l00117"></a>00117 }
<a name="l00118"></a>00118 
<a name="l00124"></a><a class="code" href="class_c_p_array.html#a4811e54ee87ec16819a86d24523308db">00124</a> + (id)arrayWithArray:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)anArray
<a name="l00125"></a>00125 {
<a name="l00126"></a>00126     <span class="keywordflow">return</span> [[<span class="keyword">self</span> alloc] initWithArray:anArray];
<a name="l00127"></a>00127 }
<a name="l00128"></a>00128 
<a name="l00134"></a><a class="code" href="class_c_p_array.html#a75a09e8530bb9a8d7084f11df833674d">00134</a> + (id)arrayWithObject:(<span class="keywordtype">id</span>)anObject
<a name="l00135"></a>00135 {
<a name="l00136"></a>00136     <span class="keywordflow">return</span> [[<span class="keyword">self</span> alloc] initWithObjects:anObject];
<a name="l00137"></a>00137 }
<a name="l00138"></a>00138 
<a name="l00144"></a><a class="code" href="class_c_p_array.html#ad27bec32a9288edb5e9c6e83d2e5e8ad">00144</a> + (id)arrayWithObjects:(<span class="keywordtype">id</span>)anObject, ...
<a name="l00145"></a>00145 {
<a name="l00146"></a>00146     var i = 2,
<a name="l00147"></a>00147         <a class="code" href="class_c_p_array.html#aafeaf98dd280821940da2ec8be05b776">array</a> = [[<span class="keyword">self</span> alloc] init],
<a name="l00148"></a>00148         argument;
<a name="l00149"></a>00149 
<a name="l00150"></a>00150     <span class="keywordflow">for</span>(; i &lt; arguments.length &amp;&amp; (argument = arguments[i]) != nil; ++i)
<a name="l00151"></a>00151         <a class="code" href="class_c_p_array.html#aafeaf98dd280821940da2ec8be05b776">array</a>.push(argument);
<a name="l00152"></a>00152 
<a name="l00153"></a>00153     <span class="keywordflow">return</span> <a class="code" href="class_c_p_array.html#aafeaf98dd280821940da2ec8be05b776">array</a>;
<a name="l00154"></a>00154 }
<a name="l00155"></a>00155 
<a name="l00162"></a><a class="code" href="class_c_p_array.html#a1d4f58374dc0f3a54328aeaa04e66d21">00162</a> + (id)arrayWithObjects:(<span class="keywordtype">id</span>)objects count:(<span class="keywordtype">unsigned</span>)aCount
<a name="l00163"></a>00163 {
<a name="l00164"></a>00164     <span class="keywordflow">return</span> [[<span class="keyword">self</span> alloc] initWithObjects:objects count:aCount];
<a name="l00165"></a>00165 }
<a name="l00166"></a>00166 
<a name="l00171"></a><a class="code" href="class_c_p_array.html#a1a39ec2ac006d880f2aac3d3ee8152f1">00171</a> - (id)<a class="code" href="class_c_p_array.html#a1a39ec2ac006d880f2aac3d3ee8152f1">init</a>
<a name="l00172"></a>00172 {
<a name="l00173"></a>00173     <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00174"></a>00174 }
<a name="l00175"></a>00175 
<a name="l00176"></a>00176 <span class="comment">// Creating an Array</span>
<a name="l00182"></a><a class="code" href="class_c_p_array.html#ad5f71e47e938f27d974c1d19a6833694">00182</a> <span class="comment"></span>- (id)initWithArray:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)anArray
<a name="l00183"></a>00183 {
<a name="l00184"></a>00184     <span class="keyword">self</span> = [<span class="keyword">super</span> init];
<a name="l00185"></a>00185     
<a name="l00186"></a>00186     <span class="keywordflow">if</span> (<span class="keyword">self</span>)
<a name="l00187"></a>00187         [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#a0d51d99c720b9c6c91d3edd8be706194">setArray</a>:anArray];
<a name="l00188"></a>00188     
<a name="l00189"></a>00189     <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00190"></a>00190 }
<a name="l00191"></a>00191 
<a name="l00200"></a><a class="code" href="class_c_p_array.html#a595f86d5f78d49a973d0fb303cbdfdcc">00200</a> - (id)initWithArray:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)anArray copyItems:(BOOL)copyItems
<a name="l00201"></a>00201 {
<a name="l00202"></a>00202     <span class="keywordflow">if</span> (!copyItems)
<a name="l00203"></a>00203         <span class="keywordflow">return</span> [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#ad5f71e47e938f27d974c1d19a6833694">initWithArray</a>:anArray];
<a name="l00204"></a>00204 
<a name="l00205"></a>00205     <span class="keyword">self</span> = [<span class="keyword">super</span> init];
<a name="l00206"></a>00206     
<a name="l00207"></a>00207     <span class="keywordflow">if</span> (<span class="keyword">self</span>)
<a name="l00208"></a>00208     {
<a name="l00209"></a>00209         var index = 0,
<a name="l00210"></a>00210             <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = [anArray <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>];
<a name="l00211"></a>00211             
<a name="l00212"></a>00212         <span class="keywordflow">for</span>(; index &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>; ++index)
<a name="l00213"></a>00213         {
<a name="l00214"></a>00214             <span class="keywordflow">if</span> (anArray[index].<a class="code" href="_c_p_array_8j.html#a702f174ccd5ff8e1139f8657a0bba6fd">isa</a>)
<a name="l00215"></a>00215                 <span class="keyword">self</span>[index] = [anArray[index] <a class="code" href="class_c_p_array.html#a42447f9f646fd3ccf93c4fe864bcbd81">copy</a>];
<a name="l00216"></a>00216             <span class="comment">// Do a deep/shallow copy?</span>
<a name="l00217"></a>00217             <span class="keywordflow">else</span>
<a name="l00218"></a>00218                 <span class="keyword">self</span>[index] = anArray;
<a name="l00219"></a>00219         }
<a name="l00220"></a>00220     }
<a name="l00221"></a>00221     
<a name="l00222"></a>00222     <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00223"></a>00223 }
<a name="l00224"></a>00224 
<a name="l00228"></a><a class="code" href="class_c_p_array.html#abb48ff391e5c330be126c6abd372fe31">00228</a> - (id)initWithObjects:(Array)anArray, ...
<a name="l00229"></a>00229 {
<a name="l00230"></a>00230     <span class="comment">// The arguments array contains self and _cmd, so the first object is at position 2.</span>
<a name="l00231"></a>00231     var i = 2,
<a name="l00232"></a>00232         argument;
<a name="l00233"></a>00233     
<a name="l00234"></a>00234     <span class="keywordflow">for</span>(; i &lt; arguments.length &amp;&amp; (argument = arguments[i]) != nil; ++i)
<a name="l00235"></a>00235         push(argument);
<a name="l00236"></a>00236 
<a name="l00237"></a>00237     <span class="keywordflow">return</span> <span class="keyword">self</span>; 
<a name="l00238"></a>00238 }
<a name="l00239"></a>00239 
<a name="l00246"></a><a class="code" href="class_c_p_array.html#abe531ead65c7a54c7e6bd857be10eaaf">00246</a> - (id)initWithObjects:(<span class="keywordtype">id</span>)objects count:(<span class="keywordtype">unsigned</span>)aCount
<a name="l00247"></a>00247 {
<a name="l00248"></a>00248     <span class="keyword">self</span> = [<span class="keyword">super</span> init];
<a name="l00249"></a>00249     
<a name="l00250"></a>00250     <span class="keywordflow">if</span> (<span class="keyword">self</span>)
<a name="l00251"></a>00251     {
<a name="l00252"></a>00252         var index = 0;
<a name="l00253"></a>00253     
<a name="l00254"></a>00254         <span class="keywordflow">for</span>(; index &lt; aCount; ++index)
<a name="l00255"></a>00255             push(objects[index]);
<a name="l00256"></a>00256     }
<a name="l00257"></a>00257 
<a name="l00258"></a>00258     <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00259"></a>00259 }
<a name="l00260"></a>00260 
<a name="l00261"></a>00261 <span class="comment">// Querying an array</span>
<a name="l00266"></a><a class="code" href="class_c_p_array.html#a2b1a8bda409226dd4e96c3adcec313e8">00266</a> <span class="comment"></span>- (BOOL)containsObject:(<span class="keywordtype">id</span>)anObject
<a name="l00267"></a>00267 {
<a name="l00268"></a>00268     <span class="keywordflow">return</span> [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#a82a05b1fe09da8d19483829996162576">indexOfObject</a>:anObject] != <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>;
<a name="l00269"></a>00269 }
<a name="l00270"></a>00270 
<a name="l00274"></a><a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">00274</a> - (int)<a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>
<a name="l00275"></a>00275 {
<a name="l00276"></a>00276     <span class="keywordflow">return</span> length;
<a name="l00277"></a>00277 }
<a name="l00278"></a>00278 
<a name="l00286"></a><a class="code" href="class_c_p_array.html#a82a05b1fe09da8d19483829996162576">00286</a> - (int)indexOfObject:(<span class="keywordtype">id</span>)anObject
<a name="l00287"></a>00287 {
<a name="l00288"></a>00288     <span class="keywordflow">if</span> (anObject === nil)
<a name="l00289"></a>00289         <span class="keywordflow">return</span> <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>;
<a name="l00290"></a>00290     
<a name="l00291"></a>00291     var i = 0, 
<a name="l00292"></a>00292         <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = length;
<a name="l00293"></a>00293 
<a name="l00294"></a>00294     <span class="comment">// Only use -isEqual: if our object is a CPObject.</span>
<a name="l00295"></a>00295     <span class="keywordflow">if</span> (anObject.isa)
<a name="l00296"></a>00296     {
<a name="l00297"></a>00297         <span class="keywordflow">for</span>(; i &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>; ++i)
<a name="l00298"></a>00298             <span class="keywordflow">if</span>([<span class="keyword">self</span>[i] isEqual:anObject])
<a name="l00299"></a>00299                 <span class="keywordflow">return</span> i;
<a name="l00300"></a>00300     }
<a name="l00301"></a>00301     <span class="comment">// If indexOf exists, use it since it&apos;s probably </span>
<a name="l00302"></a>00302     <span class="comment">// faster than anything we can implement.</span>
<a name="l00303"></a>00303     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keyword">self</span>.indexOf)
<a name="l00304"></a>00304         <span class="keywordflow">return</span> indexOf(anObject);
<a name="l00305"></a>00305     <span class="comment">// Last resort, do a straight forward linear O(N) search.</span>
<a name="l00306"></a>00306     <span class="keywordflow">else</span>
<a name="l00307"></a>00307         <span class="keywordflow">for</span>(; i &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>; ++i)
<a name="l00308"></a>00308             <span class="keywordflow">if</span>(<span class="keyword">self</span>[i] == anObject)
<a name="l00309"></a>00309                 <span class="keywordflow">return</span> i;
<a name="l00310"></a>00310     
<a name="l00311"></a>00311     <span class="keywordflow">return</span> <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>;
<a name="l00312"></a>00312 }
<a name="l00313"></a>00313 
<a name="l00322"></a><a class="code" href="class_c_p_array.html#a3a19559151fe2851fe7b059c7c977cec">00322</a> - (int)indexOfObject:(<span class="keywordtype">id</span>)anObject inRange:(CPRange)aRange
<a name="l00323"></a>00323 {
<a name="l00324"></a>00324     <span class="keywordflow">if</span> (anObject === nil)
<a name="l00325"></a>00325         <span class="keywordflow">return</span> <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>;
<a name="l00326"></a>00326     
<a name="l00327"></a>00327     var i = aRange.location, 
<a name="l00328"></a>00328         <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = <a class="code" href="_c_p_obj_j_runtime_8j.html#a4fca277171215842609dc38a6f0c19fb">MIN</a>(<a class="code" href="group__foundation.html#ga9a9c6e53b2b0861cedbb77b5ab72e78f">CPMaxRange</a>(aRange), length);
<a name="l00329"></a>00329     
<a name="l00330"></a>00330     <span class="comment">// Only use isEqual: if our object is a CPObject.</span>
<a name="l00331"></a>00331     <span class="keywordflow">if</span> (anObject.isa)
<a name="l00332"></a>00332     {
<a name="l00333"></a>00333         <span class="keywordflow">for</span>(; i &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>; ++i)
<a name="l00334"></a>00334             <span class="keywordflow">if</span>([<span class="keyword">self</span>[i] isEqual:anObject])
<a name="l00335"></a>00335                 <span class="keywordflow">return</span> i;
<a name="l00336"></a>00336     }
<a name="l00337"></a>00337     <span class="comment">// Last resort, do a straight forward linear O(N) search.</span>
<a name="l00338"></a>00338     <span class="keywordflow">else</span>
<a name="l00339"></a>00339         <span class="keywordflow">for</span>(; i &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>; ++i)
<a name="l00340"></a>00340             <span class="keywordflow">if</span>(<span class="keyword">self</span>[i] == anObject)
<a name="l00341"></a>00341                 <span class="keywordflow">return</span> i;
<a name="l00342"></a>00342     
<a name="l00343"></a>00343     <span class="keywordflow">return</span> <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>;
<a name="l00344"></a>00344 }
<a name="l00345"></a>00345 
<a name="l00351"></a><a class="code" href="class_c_p_array.html#a59db6f14ec0b5dac60f2d59564f1a74a">00351</a> - (int)indexOfObjectIdenticalTo:(<span class="keywordtype">id</span>)anObject
<a name="l00352"></a>00352 {
<a name="l00353"></a>00353     <span class="keywordflow">if</span> (anObject === nil)
<a name="l00354"></a>00354         <span class="keywordflow">return</span> <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>;
<a name="l00355"></a>00355     
<a name="l00356"></a>00356     <span class="comment">// If indexOf exists, use it since it&apos;s probably </span>
<a name="l00357"></a>00357     <span class="comment">// faster than anything we can implement.</span>
<a name="l00358"></a>00358     <span class="keywordflow">if</span> (<span class="keyword">self</span>.indexOf)
<a name="l00359"></a>00359         <span class="keywordflow">return</span> indexOf(anObject);
<a name="l00360"></a>00360     
<a name="l00361"></a>00361     <span class="comment">// Last resort, do a straight forward linear O(N) search.</span>
<a name="l00362"></a>00362     <span class="keywordflow">else</span>
<a name="l00363"></a>00363     {
<a name="l00364"></a>00364         var index = 0, 
<a name="l00365"></a>00365             <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = length;
<a name="l00366"></a>00366         
<a name="l00367"></a>00367         <span class="keywordflow">for</span>(; index &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>; ++index)
<a name="l00368"></a>00368             <span class="keywordflow">if</span>(<span class="keyword">self</span>[index] === anObject)
<a name="l00369"></a>00369                 <span class="keywordflow">return</span> index;
<a name="l00370"></a>00370     }
<a name="l00371"></a>00371     
<a name="l00372"></a>00372     <span class="keywordflow">return</span> <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>;
<a name="l00373"></a>00373 }
<a name="l00374"></a>00374 
<a name="l00383"></a><a class="code" href="class_c_p_array.html#aa556f0be5192dc78b9440917551c82cf">00383</a> - (int)indexOfObjectIdenticalTo:(<span class="keywordtype">id</span>)anObject inRange:(CPRange)aRange
<a name="l00384"></a>00384 {
<a name="l00385"></a>00385     <span class="keywordflow">if</span> (anObject === nil)
<a name="l00386"></a>00386         <span class="keywordflow">return</span> <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>;
<a name="l00387"></a>00387     
<a name="l00388"></a>00388     <span class="comment">// If indexOf exists, use it since it&apos;s probably </span>
<a name="l00389"></a>00389     <span class="comment">// faster than anything we can implement.</span>
<a name="l00390"></a>00390     <span class="keywordflow">if</span> (<span class="keyword">self</span>.indexOf)
<a name="l00391"></a>00391     {
<a name="l00392"></a>00392         var index = indexOf(anObject, aRange.location);
<a name="l00393"></a>00393         
<a name="l00394"></a>00394         <span class="keywordflow">if</span> (<a class="code" href="group__foundation.html#ga11d8b85f5a9d54a56c269d269745c671">CPLocationInRange</a>(index, aRange))
<a name="l00395"></a>00395             <span class="keywordflow">return</span> index;
<a name="l00396"></a>00396     }
<a name="l00397"></a>00397     
<a name="l00398"></a>00398     <span class="comment">// Last resort, do a straight forward linear O(N) search.</span>
<a name="l00399"></a>00399     <span class="keywordflow">else</span>
<a name="l00400"></a>00400     {
<a name="l00401"></a>00401         var index = aRange.location, 
<a name="l00402"></a>00402             <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = <a class="code" href="_c_p_obj_j_runtime_8j.html#a4fca277171215842609dc38a6f0c19fb">MIN</a>(<a class="code" href="group__foundation.html#ga9a9c6e53b2b0861cedbb77b5ab72e78f">CPMaxRange</a>(aRange), length);
<a name="l00403"></a>00403         
<a name="l00404"></a>00404         <span class="keywordflow">for</span>(; index &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>; ++index)
<a name="l00405"></a>00405             <span class="keywordflow">if</span>(<span class="keyword">self</span>[index] == anObject)
<a name="l00406"></a>00406                 <span class="keywordflow">return</span> index;
<a name="l00407"></a>00407     }
<a name="l00408"></a>00408     
<a name="l00409"></a>00409     <span class="keywordflow">return</span> <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>;
<a name="l00410"></a>00410 }
<a name="l00411"></a>00411 
<a name="l00420"></a><a class="code" href="class_c_p_array.html#ad870d7e316197ab24403428e8f005dde">00420</a> - (unsigned)indexOfObject:(<span class="keywordtype">id</span>)anObject sortedBySelector:(<span class="keywordtype">SEL</span>)aSelector
<a name="l00421"></a>00421 {
<a name="l00422"></a>00422     <span class="keywordflow">return</span> [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#a999151c1417d6afdd0f6c20d49455c4e">indexOfObject</a>:anObject <a class="code" href="class_c_p_array.html#a999151c1417d6afdd0f6c20d49455c4e">sortedByFunction</a>: function(lhs, rhs) { objj_msgSend(lhs, aSelector, rhs); }];
<a name="l00423"></a>00423 }
<a name="l00424"></a>00424 
<a name="l00437"></a><a class="code" href="class_c_p_array.html#a999151c1417d6afdd0f6c20d49455c4e">00437</a> - (unsigned)indexOfObject:(<span class="keywordtype">id</span>)anObject sortedByFunction:(Function)aFunction
<a name="l00438"></a>00438 {
<a name="l00439"></a>00439     <span class="keywordflow">return</span> [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#a8cd2860fbb7fdd1bc3f5762886dde73c">indexOfObject</a>:anObject <a class="code" href="class_c_p_array.html#a8cd2860fbb7fdd1bc3f5762886dde73c">sortedByFunction</a>:aFunction <a class="code" href="class_c_p_array.html#a8cd2860fbb7fdd1bc3f5762886dde73c">context</a>:nil];
<a name="l00440"></a>00440 }
<a name="l00441"></a>00441 
<a name="l00455"></a><a class="code" href="class_c_p_array.html#a8cd2860fbb7fdd1bc3f5762886dde73c">00455</a> - (unsigned)indexOfObject:(<span class="keywordtype">id</span>)anObject sortedByFunction:(Function)aFunction context:(<span class="keywordtype">id</span>)aContext
<a name="l00456"></a>00456 {
<a name="l00457"></a>00457     <span class="keywordflow">if</span> (!aFunction || anObject === undefined)
<a name="l00458"></a>00458         <span class="keywordflow">return</span> <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>;
<a name="l00459"></a>00459 
<a name="l00460"></a>00460     var mid, c, first = 0, last = length - 1;
<a name="l00461"></a>00461     <span class="keywordflow">while</span> (first &lt;= last)
<a name="l00462"></a>00462     {
<a name="l00463"></a>00463         mid = FLOOR((first + last) / 2);
<a name="l00464"></a>00464           c = aFunction(anObject, <span class="keyword">self</span>[mid], aContext);
<a name="l00465"></a>00465 
<a name="l00466"></a>00466         <span class="keywordflow">if</span> (c &gt; 0)
<a name="l00467"></a>00467             first = mid + 1;
<a name="l00468"></a>00468         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (c &lt; 0)
<a name="l00469"></a>00469             last = mid - 1;
<a name="l00470"></a>00470         <span class="keywordflow">else</span>
<a name="l00471"></a>00471         {
<a name="l00472"></a>00472             <span class="keywordflow">while</span> (mid &lt; length - 1 &amp;&amp; aFunction(anObject, <span class="keyword">self</span>[mid+1], aContext) == <a class="code" href="_c_p_obj_j_runtime_8j.html#af6563f83ad093188bcbdba78aa1848c5">CPOrderedSame</a>)
<a name="l00473"></a>00473                 mid++;
<a name="l00474"></a>00474 
<a name="l00475"></a>00475             <span class="keywordflow">return</span> mid;
<a name="l00476"></a>00476         }
<a name="l00477"></a>00477     }
<a name="l00478"></a>00478 
<a name="l00479"></a>00479     <span class="keywordflow">return</span> <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>;
<a name="l00480"></a>00480 }
<a name="l00481"></a>00481 
<a name="l00490"></a><a class="code" href="class_c_p_array.html#a6af71e3eabca7db547529937f591ad69">00490</a> - (unsigned)indexOfObject:(<span class="keywordtype">id</span>)anObject sortedByDescriptors:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)descriptors
<a name="l00491"></a>00491 {
<a name="l00492"></a>00492     <span class="keywordflow">return</span> [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#a999151c1417d6afdd0f6c20d49455c4e">indexOfObject</a>:anObject <a class="code" href="class_c_p_array.html#a999151c1417d6afdd0f6c20d49455c4e">sortedByFunction</a>:function(lhs, rhs)
<a name="l00493"></a>00493     {
<a name="l00494"></a>00494         var i = 0,
<a name="l00495"></a>00495             count = [descriptors <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>],
<a name="l00496"></a>00496             result = CPOrderedSame;
<a name="l00497"></a>00497 
<a name="l00498"></a>00498         while (i &lt; count)
<a name="l00499"></a>00499             if((result = [descriptors[i++] compareObject:lhs withObject:rhs]) != CPOrderedSame)
<a name="l00500"></a>00500                 return result;
<a name="l00501"></a>00501 
<a name="l00502"></a>00502         return result;
<a name="l00503"></a>00503     }];
<a name="l00504"></a>00504 }
<a name="l00505"></a>00505 
<a name="l00509"></a><a class="code" href="class_c_p_array.html#a8ad5370c1285197114b7b2b50928710c">00509</a> - (id)<a class="code" href="class_c_p_array.html#a8ad5370c1285197114b7b2b50928710c">lastObject</a>
<a name="l00510"></a>00510 {
<a name="l00511"></a>00511     var <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>];
<a name="l00512"></a>00512     
<a name="l00513"></a>00513     <span class="keywordflow">if</span> (!<a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>) <span class="keywordflow">return</span> nil;
<a name="l00514"></a>00514     
<a name="l00515"></a>00515     <span class="keywordflow">return</span> <span class="keyword">self</span>[count - 1];
<a name="l00516"></a>00516 }
<a name="l00517"></a>00517 
<a name="l00522"></a><a class="code" href="class_c_p_array.html#a5f4c80df5e0ce9c9c7c64c7c24d917eb">00522</a> - (id)objectAtIndex:(<span class="keywordtype">int</span>)anIndex
<a name="l00523"></a>00523 {
<a name="l00524"></a>00524     <span class="keywordflow">if</span> (anIndex &gt;= length || anIndex &lt; 0)
<a name="l00525"></a>00525         [<a class="code" href="class_c_p_exception.html" title="Used to implement exception handling (creating &amp;amp; raising).">CPException</a> <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">raise</a>:CPRangeException <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">reason</a>:@&quot;index (&quot; + anIndex + @&quot;) beyond bounds (&quot; + length + @&quot;)&quot;];
<a name="l00526"></a>00526 
<a name="l00527"></a>00527     <span class="keywordflow">return</span> <span class="keyword">self</span>[anIndex];
<a name="l00528"></a>00528 }
<a name="l00529"></a>00529 
<a name="l00535"></a><a class="code" href="class_c_p_array.html#a3920f7f80d09758ccde326aeabb8e5c8">00535</a> - (<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)objectsAtIndexes:(<a class="code" href="class_c_p_index_set.html" title="A collection of unique integers.">CPIndexSet</a>)indexes
<a name="l00536"></a>00536 {
<a name="l00537"></a>00537     var index = <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>,
<a name="l00538"></a>00538         objects = [];
<a name="l00539"></a>00539 
<a name="l00540"></a>00540     <span class="keywordflow">while</span>((index = [indexes indexGreaterThanIndex:index]) !== <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>)
<a name="l00541"></a>00541         [objects addObject:[<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#a5f4c80df5e0ce9c9c7c64c7c24d917eb">objectAtIndex</a>:index]];
<a name="l00542"></a>00542 
<a name="l00543"></a>00543     <span class="keywordflow">return</span> objects;
<a name="l00544"></a>00544 }
<a name="l00545"></a>00545 
<a name="l00551"></a><a class="code" href="class_c_p_array.html#a5d5d6488d823ab32b142a5cc246d288b">00551</a> - (<a class="code" href="class_c_p_enumerator.html" title="Defines an interface for enumerators.">CPEnumerator</a>)<a class="code" href="class_c_p_array.html#a5d5d6488d823ab32b142a5cc246d288b">objectEnumerator</a>
<a name="l00552"></a>00552 {
<a name="l00553"></a>00553     <span class="keywordflow">return</span> [[_CPArrayEnumerator alloc] initWithArray:self];
<a name="l00554"></a>00554 }
<a name="l00555"></a>00555 
<a name="l00561"></a><a class="code" href="class_c_p_array.html#a7930d0e67d9cac4719eba381f127b259">00561</a> - (<a class="code" href="class_c_p_enumerator.html" title="Defines an interface for enumerators.">CPEnumerator</a>)<a class="code" href="class_c_p_array.html#a7930d0e67d9cac4719eba381f127b259">reverseObjectEnumerator</a>
<a name="l00562"></a>00562 {
<a name="l00563"></a>00563     <span class="keywordflow">return</span> [[_CPReverseArrayEnumerator alloc] initWithArray:self];
<a name="l00564"></a>00564 }
<a name="l00565"></a>00565 
<a name="l00566"></a>00566 <span class="comment">// Sending messages to elements</span>
<a name="l00572"></a><a class="code" href="class_c_p_array.html#ab2b812f3569cf5ad31b08ef3b1ef4b0e">00572</a> <span class="comment"></span>- (void)makeObjectsPerformSelector:(<span class="keywordtype">SEL</span>)aSelector
<a name="l00573"></a>00573 {
<a name="l00574"></a>00574     <span class="keywordflow">if</span> (!aSelector)
<a name="l00575"></a>00575         [<a class="code" href="class_c_p_exception.html" title="Used to implement exception handling (creating &amp;amp; raising).">CPException</a> <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">raise</a>:CPInvalidArgumentException <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">reason</a>:&quot;makeObjectsPerformSelector: &apos;aSelector&apos; can&apos;t be nil&quot;];
<a name="l00576"></a>00576     
<a name="l00577"></a>00577     var index = 0, 
<a name="l00578"></a>00578         <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = length;
<a name="l00579"></a>00579         
<a name="l00580"></a>00580     <span class="keywordflow">for</span>(; index &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>; ++index)
<a name="l00581"></a>00581         objj_msgSend(<span class="keyword">self</span>[index], aSelector);
<a name="l00582"></a>00582 }
<a name="l00583"></a>00583 
<a name="l00590"></a><a class="code" href="class_c_p_array.html#aa381a88315ad7d20d660c2260ba55937">00590</a> - (void)makeObjectsPerformSelector:(<span class="keywordtype">SEL</span>)aSelector withObject:(<span class="keywordtype">id</span>)anObject
<a name="l00591"></a>00591 {
<a name="l00592"></a>00592     <span class="keywordflow">if</span> (!aSelector)
<a name="l00593"></a>00593         [<a class="code" href="class_c_p_exception.html" title="Used to implement exception handling (creating &amp;amp; raising).">CPException</a> <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">raise</a>:CPInvalidArgumentException <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">reason</a>:&quot;makeObjectsPerformSelector:withObject &apos;aSelector&apos; can&apos;t be nil&quot;];
<a name="l00594"></a>00594 
<a name="l00595"></a>00595     var index = 0, 
<a name="l00596"></a>00596         <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = length;
<a name="l00597"></a>00597         
<a name="l00598"></a>00598     <span class="keywordflow">for</span>(; index &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>; ++index) 
<a name="l00599"></a>00599         objj_msgSend(<span class="keyword">self</span>[index], aSelector, anObject);
<a name="l00600"></a>00600 }
<a name="l00601"></a>00601 
<a name="l00602"></a><a class="code" href="class_c_p_array.html#a4912d66f0e2c9d9148e828aa911cbef2">00602</a> - (void)makeObjectsPerformSelector:(<span class="keywordtype">SEL</span>)aSelector withObjects:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)objects
<a name="l00603"></a>00603 {
<a name="l00604"></a>00604     <span class="keywordflow">if</span> (!aSelector)
<a name="l00605"></a>00605         [<a class="code" href="class_c_p_exception.html" title="Used to implement exception handling (creating &amp;amp; raising).">CPException</a> <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">raise</a>:CPInvalidArgumentException <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">reason</a>:&quot;makeObjectsPerformSelector:withObjects: &apos;aSelector&apos; can&apos;t be nil&quot;];
<a name="l00606"></a>00606 
<a name="l00607"></a>00607     var index = 0,
<a name="l00608"></a>00608         <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = length,
<a name="l00609"></a>00609         argumentsArray = [nil, aSelector].concat(objects || []);
<a name="l00610"></a>00610 
<a name="l00611"></a>00611     <span class="keywordflow">for</span>(; index &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>; ++index)
<a name="l00612"></a>00612     {
<a name="l00613"></a>00613         argumentsArray[0] = <span class="keyword">self</span>[index];
<a name="l00614"></a>00614         objj_msgSend.apply(<span class="keyword">this</span>, argumentsArray);
<a name="l00615"></a>00615     }
<a name="l00616"></a>00616 }
<a name="l00617"></a>00617 
<a name="l00618"></a>00618 
<a name="l00619"></a>00619 <span class="comment">// Comparing arrays</span>
<a name="l00625"></a><a class="code" href="class_c_p_array.html#aa408913568c10cb8fb8a03e2741d4f3e">00625</a> <span class="comment"></span>- (id)firstObjectCommonWithArray:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)anArray
<a name="l00626"></a>00626 {
<a name="l00627"></a>00627     <span class="keywordflow">if</span> (![anArray <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>] || ![<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>])
<a name="l00628"></a>00628         <span class="keywordflow">return</span> nil;
<a name="l00629"></a>00629     
<a name="l00630"></a>00630     var i = 0,
<a name="l00631"></a>00631         <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>];
<a name="l00632"></a>00632 
<a name="l00633"></a>00633     <span class="keywordflow">for</span>(; i &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>; ++i)
<a name="l00634"></a>00634         <span class="keywordflow">if</span>([anArray containsObject:<span class="keyword">self</span>[i]])
<a name="l00635"></a>00635             <span class="keywordflow">return</span> <span class="keyword">self</span>[i];
<a name="l00636"></a>00636 
<a name="l00637"></a>00637     <span class="keywordflow">return</span> nil;
<a name="l00638"></a>00638 }
<a name="l00639"></a>00639 
<a name="l00643"></a><a class="code" href="class_c_p_array.html#a93a59e163bf000359d2faccf7dc16b3d">00643</a> - (BOOL)isEqualToArray:(<span class="keywordtype">id</span>)anArray
<a name="l00644"></a>00644 {
<a name="l00645"></a>00645     <span class="keywordflow">if</span> (<span class="keyword">self</span> === anArray)
<a name="l00646"></a>00646         <span class="keywordflow">return</span> YES;
<a name="l00647"></a>00647     
<a name="l00648"></a>00648     <span class="keywordflow">if</span>(length != anArray.length)
<a name="l00649"></a>00649         <span class="keywordflow">return</span> NO;
<a name="l00650"></a>00650     
<a name="l00651"></a>00651     var index = 0,
<a name="l00652"></a>00652         <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>];
<a name="l00653"></a>00653     
<a name="l00654"></a>00654     <span class="keywordflow">for</span>(; index &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>; ++index)
<a name="l00655"></a>00655     {
<a name="l00656"></a>00656         var lhs = <span class="keyword">self</span>[index],
<a name="l00657"></a>00657             rhs = anArray[index];
<a name="l00658"></a>00658         
<a name="l00659"></a>00659         <span class="comment">// If they&apos;re not equal, and either doesn&apos;t have an isa, or they&apos;re !isEqual (not isEqual)</span>
<a name="l00660"></a>00660         <span class="keywordflow">if</span> (lhs !== rhs &amp;&amp; (lhs &amp;&amp; !lhs.isa || rhs &amp;&amp; !rhs.isa || ![lhs isEqual:rhs]))
<a name="l00661"></a>00661             <span class="keywordflow">return</span> NO;
<a name="l00662"></a>00662     }
<a name="l00663"></a>00663         
<a name="l00664"></a>00664     <span class="keywordflow">return</span> YES;
<a name="l00665"></a>00665 }
<a name="l00666"></a>00666 
<a name="l00667"></a><a class="code" href="class_c_p_array.html#abca78a9caeb8bff0b7072e02eef640bd">00667</a> - (BOOL)isEqual:(<span class="keywordtype">id</span>)anObject
<a name="l00668"></a>00668 {
<a name="l00669"></a>00669     <span class="keywordflow">if</span> (<span class="keyword">self</span> === anObject)
<a name="l00670"></a>00670         <span class="keywordflow">return</span> YES;
<a name="l00671"></a>00671     
<a name="l00672"></a>00672     <span class="keywordflow">if</span>(![anObject isKindOfClass:[<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a> <span class="keyword">class</span>]])
<a name="l00673"></a>00673         <span class="keywordflow">return</span> NO;
<a name="l00674"></a>00674 
<a name="l00675"></a>00675     <span class="keywordflow">return</span> [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#a93a59e163bf000359d2faccf7dc16b3d">isEqualToArray</a>:anObject];
<a name="l00676"></a>00676 }
<a name="l00677"></a>00677 
<a name="l00678"></a>00678 <span class="comment">// Deriving new arrays</span>
<a name="l00685"></a><a class="code" href="class_c_p_array.html#a0cd571ae94a2cf76b747d7fc1439c96a">00685</a> <span class="comment"></span>- (<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)arrayByAddingObject:(<span class="keywordtype">id</span>)anObject
<a name="l00686"></a>00686 {
<a name="l00687"></a>00687     <span class="keywordflow">if</span> (anObject === nil || anObject === undefined)
<a name="l00688"></a>00688         [<a class="code" href="class_c_p_exception.html" title="Used to implement exception handling (creating &amp;amp; raising).">CPException</a> <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">raise</a>:CPInvalidArgumentException
<a name="l00689"></a>00689                     <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">reason</a>:&quot;arrayByAddingObject: object can&apos;t be nil&quot;];
<a name="l00690"></a>00690 
<a name="l00691"></a>00691     var <a class="code" href="class_c_p_array.html#aafeaf98dd280821940da2ec8be05b776">array</a> = [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#a42447f9f646fd3ccf93c4fe864bcbd81">copy</a>];
<a name="l00692"></a>00692     
<a name="l00693"></a>00693     <a class="code" href="class_c_p_array.html#aafeaf98dd280821940da2ec8be05b776">array</a>.push(anObject);
<a name="l00694"></a>00694     
<a name="l00695"></a>00695     <span class="keywordflow">return</span> <a class="code" href="class_c_p_array.html#aafeaf98dd280821940da2ec8be05b776">array</a>;
<a name="l00696"></a>00696 }
<a name="l00697"></a>00697 
<a name="l00702"></a><a class="code" href="class_c_p_array.html#a8cc60ef668ed6d0987bde8ae2dc05479">00702</a> - (<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)arrayByAddingObjectsFromArray:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)anArray
<a name="l00703"></a>00703 {
<a name="l00704"></a>00704     <span class="keywordflow">return</span> slice(0).concat(anArray);
<a name="l00705"></a>00705 }
<a name="l00706"></a>00706 
<a name="l00707"></a>00707 <span class="comment">/*  </span>
<a name="l00708"></a>00708 <span class="comment">- (CPArray)filteredArrayUsingPredicate:(CPPredicate)aPredicate</span>
<a name="l00709"></a>00709 <span class="comment">{</span>
<a name="l00710"></a>00710 <span class="comment">    var i= 0, </span>
<a name="l00711"></a>00711 <span class="comment">        count = [self count],</span>
<a name="l00712"></a>00712 <span class="comment">        array = [CPArray array];</span>
<a name="l00713"></a>00713 <span class="comment">    </span>
<a name="l00714"></a>00714 <span class="comment">    for(; i&lt;count; ++i)</span>
<a name="l00715"></a>00715 <span class="comment">        if(aPredicate.evaluateWithObject(self[i]))</span>
<a name="l00716"></a>00716 <span class="comment">            array.push(self[i]);</span>
<a name="l00717"></a>00717 <span class="comment">    </span>
<a name="l00718"></a>00718 <span class="comment">    return array;</span>
<a name="l00719"></a>00719 <span class="comment">}</span>
<a name="l00720"></a>00720 <span class="comment">*/</span>
<a name="l00721"></a>00721 
<a name="l00727"></a><a class="code" href="class_c_p_array.html#ad3ba13850e900684e79c8de165ad3c56">00727</a> - (<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)subarrayWithRange:(CPRange)aRange
<a name="l00728"></a>00728 {
<a name="l00729"></a>00729     <span class="keywordflow">if</span> (aRange.location &lt; 0 || <a class="code" href="group__foundation.html#ga9a9c6e53b2b0861cedbb77b5ab72e78f">CPMaxRange</a>(aRange) &gt; length)
<a name="l00730"></a>00730         [<a class="code" href="class_c_p_exception.html" title="Used to implement exception handling (creating &amp;amp; raising).">CPException</a> <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">raise</a>:CPRangeException <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">reason</a>:&quot;subarrayWithRange: aRange out of bounds&quot;];
<a name="l00731"></a>00731 
<a name="l00732"></a>00732     <span class="keywordflow">return</span> slice(aRange.location, <a class="code" href="group__foundation.html#ga9a9c6e53b2b0861cedbb77b5ab72e78f">CPMaxRange</a>(aRange));
<a name="l00733"></a>00733 }
<a name="l00734"></a>00734 
<a name="l00735"></a>00735 <span class="comment">// Sorting arrays</span>
<a name="l00736"></a>00736 <span class="comment">/*</span>
<a name="l00737"></a>00737 <span class="comment">    Not yet described.</span>
<a name="l00738"></a>00738 <span class="comment">*/</span>
<a name="l00739"></a><a class="code" href="class_c_p_array.html#a3565f5efa875a86fceed1593c9734a0a">00739</a> - (<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)sortedArrayUsingDescriptors:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)descriptors
<a name="l00740"></a>00740 {
<a name="l00741"></a>00741     var sorted = [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#a42447f9f646fd3ccf93c4fe864bcbd81">copy</a>];
<a name="l00742"></a>00742     
<a name="l00743"></a>00743     [sorted sortUsingDescriptors:descriptors];
<a name="l00744"></a>00744     
<a name="l00745"></a>00745     <span class="keywordflow">return</span> sorted;
<a name="l00746"></a>00746 }
<a name="l00747"></a>00747 
<a name="l00751"></a><a class="code" href="class_c_p_array.html#a6a21fbf8887827356569c535c172c7de">00751</a> - (<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)sortedArrayUsingFunction:(Function)aFunction
<a name="l00752"></a>00752 {
<a name="l00753"></a>00753     <span class="keywordflow">return</span> [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#a019924ca870ae9344a91aba79625fdee">sortedArrayUsingFunction</a>:aFunction <a class="code" href="class_c_p_array.html#a019924ca870ae9344a91aba79625fdee">context</a>:nil];
<a name="l00754"></a>00754 }
<a name="l00755"></a>00755 
<a name="l00764"></a><a class="code" href="class_c_p_array.html#a019924ca870ae9344a91aba79625fdee">00764</a> - (<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)sortedArrayUsingFunction:(Function)aFunction context:(<span class="keywordtype">id</span>)aContext
<a name="l00765"></a>00765 {
<a name="l00766"></a>00766     var sorted = [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#a42447f9f646fd3ccf93c4fe864bcbd81">copy</a>];
<a name="l00767"></a>00767     
<a name="l00768"></a>00768     [sorted sortUsingFunction:aFunction context:aContext];
<a name="l00769"></a>00769     
<a name="l00770"></a>00770     <span class="keywordflow">return</span> sorted;
<a name="l00771"></a>00771 }
<a name="l00772"></a>00772 
<a name="l00777"></a><a class="code" href="class_c_p_array.html#a4ff18edaebc988594b2ead10cd69a647">00777</a> - (<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)sortedArrayUsingSelector:(<span class="keywordtype">SEL</span>)aSelector
<a name="l00778"></a>00778 {
<a name="l00779"></a>00779     var sorted = [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#a42447f9f646fd3ccf93c4fe864bcbd81">copy</a>]
<a name="l00780"></a>00780     
<a name="l00781"></a>00781     [sorted sortUsingSelector:aSelector];
<a name="l00782"></a>00782 
<a name="l00783"></a>00783     <span class="keywordflow">return</span> sorted;
<a name="l00784"></a>00784 }
<a name="l00785"></a>00785 
<a name="l00786"></a>00786 <span class="comment">// Working with string elements</span>
<a name="l00787"></a>00787 
<a name="l00796"></a><a class="code" href="class_c_p_array.html#adaea28fa0eb14f2941542c50d3c1545a">00796</a> - (<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)componentsJoinedByString:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aString
<a name="l00797"></a>00797 {
<a name="l00798"></a>00798     <span class="comment">// Objective-J objects get &quot;description&quot; called on them automatically when coerced to strings</span>
<a name="l00799"></a>00799     <span class="comment">// (see &quot;objj_object.prototype.toString&quot; at bottom of CPObject.j)</span>
<a name="l00800"></a>00800     <span class="keywordflow">return</span> join(aString);
<a name="l00801"></a>00801 }
<a name="l00802"></a>00802 
<a name="l00803"></a>00803 <span class="comment">// Creating a description of the array</span>
<a name="l00804"></a>00804 
<a name="l00808"></a><a class="code" href="class_c_p_array.html#a7fe2e4958fa541e8631d96b1825cc8df">00808</a> - (<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)<a class="code" href="class_c_p_array.html#a7fe2e4958fa541e8631d96b1825cc8df">description</a>
<a name="l00809"></a>00809 {
<a name="l00810"></a>00810     var index = 0,
<a name="l00811"></a>00811         <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>],
<a name="l00812"></a>00812         <a class="code" href="class_c_p_array.html#a7fe2e4958fa541e8631d96b1825cc8df">description</a> = <span class="charliteral">&apos;(&apos;</span>;
<a name="l00813"></a>00813 
<a name="l00814"></a>00814     <span class="keywordflow">for</span>(; index &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>; ++index)
<a name="l00815"></a>00815     {
<a name="l00816"></a>00816         <span class="keywordflow">if</span> (index === 0)
<a name="l00817"></a>00817             <a class="code" href="class_c_p_array.html#a7fe2e4958fa541e8631d96b1825cc8df">description</a> += <span class="charliteral">&apos;\n&apos;</span>;
<a name="l00818"></a>00818 
<a name="l00819"></a>00819         var <span class="keywordtype">object</span> = [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#a5f4c80df5e0ce9c9c7c64c7c24d917eb">objectAtIndex</a>:index],
<a name="l00820"></a>00820             objectDescription = <span class="keywordtype">object</span> &amp;&amp; <span class="keywordtype">object</span>.isa ? [object description] : String(<span class="keywordtype">object</span>);
<a name="l00821"></a>00821 
<a name="l00822"></a>00822         <a class="code" href="class_c_p_array.html#a7fe2e4958fa541e8631d96b1825cc8df">description</a> += <span class="stringliteral">&quot;\t&quot;</span> + objectDescription.split(<span class="charliteral">&apos;\n&apos;</span>).join(<span class="stringliteral">&quot;\n\t&quot;</span>);
<a name="l00823"></a>00823 
<a name="l00824"></a>00824         <span class="keywordflow">if</span> (index !== <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> - 1)
<a name="l00825"></a>00825             <a class="code" href="class_c_p_array.html#a7fe2e4958fa541e8631d96b1825cc8df">description</a> += <span class="stringliteral">&quot;, &quot;</span>;
<a name="l00826"></a>00826 
<a name="l00827"></a>00827         <a class="code" href="class_c_p_array.html#a7fe2e4958fa541e8631d96b1825cc8df">description</a> += <span class="charliteral">&apos;\n&apos;</span>;
<a name="l00828"></a>00828     }
<a name="l00829"></a>00829 
<a name="l00830"></a>00830     <span class="keywordflow">return</span> <a class="code" href="class_c_p_array.html#a7fe2e4958fa541e8631d96b1825cc8df">description</a> + <span class="charliteral">&apos;)&apos;</span>;
<a name="l00831"></a>00831 }
<a name="l00832"></a>00832 
<a name="l00833"></a>00833 <span class="comment">// Collecting paths</span>
<a name="l00841"></a><a class="code" href="class_c_p_array.html#a26d192df725fa9020411b696437fd748">00841</a> <span class="comment"></span>- (<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)pathsMatchingExtensions:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)filterTypes
<a name="l00842"></a>00842 {
<a name="l00843"></a>00843     var index = 0,
<a name="l00844"></a>00844         <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>],
<a name="l00845"></a>00845         <a class="code" href="class_c_p_array.html#aafeaf98dd280821940da2ec8be05b776">array</a> = [];
<a name="l00846"></a>00846     
<a name="l00847"></a>00847     <span class="keywordflow">for</span>(; index &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>; ++index)
<a name="l00848"></a>00848         <span class="keywordflow">if</span> (<span class="keyword">self</span>[index].<a class="code" href="_c_p_array_8j.html#a702f174ccd5ff8e1139f8657a0bba6fd">isa</a> &amp;&amp; [<span class="keyword">self</span>[index] isKindOfClass:[<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a> <span class="keyword">class</span>]] &amp;&amp; [filterTypes containsObject:[<span class="keyword">self</span>[index] pathExtension]])
<a name="l00849"></a>00849             <a class="code" href="class_c_p_array.html#aafeaf98dd280821940da2ec8be05b776">array</a>.push(<span class="keyword">self</span>[index]);
<a name="l00850"></a>00850     
<a name="l00851"></a>00851     <span class="keywordflow">return</span> <a class="code" href="class_c_p_array.html#aafeaf98dd280821940da2ec8be05b776">array</a>;
<a name="l00852"></a>00852 }
<a name="l00853"></a>00853 
<a name="l00854"></a>00854 <span class="comment">// Key value coding</span>
<a name="l00860"></a>00860 <span class="comment"></span>- (void)setValue:(<span class="keywordtype">id</span>)aValue forKey:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aKey
<a name="l00861"></a>00861 {
<a name="l00862"></a>00862     var i = 0,
<a name="l00863"></a>00863         <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = [<span class="keyword">self</span> count];
<a name="l00864"></a>00864     
<a name="l00865"></a>00865     <span class="keywordflow">for</span>(; i &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>; ++i)
<a name="l00866"></a>00866         [<a class="code" href="_c_p_button_bar_8j.html#a57945218a0d2fdfc4a2d4fa646901ef1">self</a>[i] setValue:aValue forKey:aKey];
<a name="l00867"></a>00867 }
<a name="l00868"></a>00868 
<a name="l00874"></a>00874 - (<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)valueForKey:(<a class="code" href="class_c_p_string.html" title="An immutable string (collection of characters).">CPString</a>)aKey
<a name="l00875"></a>00875 {
<a name="l00876"></a>00876     var i = 0,
<a name="l00877"></a>00877         <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = [<span class="keyword">self</span> count],
<a name="l00878"></a>00878         <a class="code" href="class_c_p_array.html#aafeaf98dd280821940da2ec8be05b776">array</a> = [];
<a name="l00879"></a>00879     
<a name="l00880"></a>00880     <span class="keywordflow">for</span>(; i &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>; ++i)
<a name="l00881"></a>00881         <a class="code" href="class_c_p_array.html#aafeaf98dd280821940da2ec8be05b776">array</a>.push([<a class="code" href="_c_p_button_bar_8j.html#a57945218a0d2fdfc4a2d4fa646901ef1">self</a>[i] valueForKey:aKey]);
<a name="l00882"></a>00882     
<a name="l00883"></a>00883     <span class="keywordflow">return</span> <a class="code" href="class_c_p_array.html#aafeaf98dd280821940da2ec8be05b776">array</a>;
<a name="l00884"></a>00884 }
<a name="l00885"></a>00885 
<a name="l00886"></a>00886 <span class="comment">// Copying arrays</span>
<a name="l00887"></a>00887 
<a name="l00892"></a><a class="code" href="class_c_p_array.html#a42447f9f646fd3ccf93c4fe864bcbd81">00892</a> - (id)<a class="code" href="class_c_p_array.html#a42447f9f646fd3ccf93c4fe864bcbd81">copy</a>
<a name="l00893"></a>00893 {
<a name="l00894"></a>00894     <span class="keywordflow">return</span> slice(0);
<a name="l00895"></a>00895 }
<a name="l00896"></a>00896     
<a name="l00897"></a>00897 <span class="keyword">@end</span>
<a name="l00898"></a>00898 
<a name="l00899"></a>00899 <span class="keyword">@implementation </span><a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>(<a class="code" href="class_c_p_mutable_array.html">CPMutableArray</a>)
<a name="l00900"></a>00900 
<a name="l00901"></a>00901 <span class="comment">// Creating arrays</span>
<a name="l00907"></a><a class="code" href="class_c_p_array.html#a8fd54c22825fa5409bff74ca03101235">00907</a> <span class="comment"></span>+ (<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)arrayWithCapacity:(<span class="keywordtype">unsigned</span>)aCapacity
<a name="l00908"></a>00908 {
<a name="l00909"></a>00909     <span class="keywordflow">return</span> [[<span class="keyword">self</span> alloc] initWithCapacity:aCapacity];
<a name="l00910"></a>00910 }
<a name="l00911"></a>00911 
<a name="l00916"></a><a class="code" href="class_c_p_array.html#a06d43ea93d0d0fd2cbe38bbc05b6cc6a">00916</a> - (id)initWithCapacity:(<span class="keywordtype">unsigned</span>)aCapacity
<a name="l00917"></a>00917 {
<a name="l00918"></a>00918     <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00919"></a>00919 }
<a name="l00920"></a>00920 
<a name="l00921"></a>00921 <span class="comment">// Adding and replacing objects</span>
<a name="l00926"></a><a class="code" href="class_c_p_array.html#aa9b30d4c68c37973bb2c61ff2bb9ba15">00926</a> <span class="comment"></span>- (void)addObject:(<span class="keywordtype">id</span>)anObject
<a name="l00927"></a>00927 {
<a name="l00928"></a>00928     push(anObject);
<a name="l00929"></a>00929 }
<a name="l00930"></a>00930 
<a name="l00935"></a><a class="code" href="class_c_p_array.html#a748d1d1cd2814924576173b08e745cbb">00935</a> - (void)addObjectsFromArray:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)anArray
<a name="l00936"></a>00936 {
<a name="l00937"></a>00937     splice.apply(<span class="keyword">self</span>, [length, 0].concat(anArray));
<a name="l00938"></a>00938 }
<a name="l00939"></a>00939 
<a name="l00945"></a><a class="code" href="class_c_p_array.html#a259c0f370b7b7616ac4ced4783db6ab7">00945</a> - (void)insertObject:(<span class="keywordtype">id</span>)anObject atIndex:(<span class="keywordtype">int</span>)anIndex
<a name="l00946"></a>00946 {
<a name="l00947"></a>00947     splice(anIndex, 0, anObject);
<a name="l00948"></a>00948 }
<a name="l00949"></a>00949 
<a name="l00955"></a><a class="code" href="class_c_p_array.html#a6b05bd0936b61aa717b32b6b5160ba6b">00955</a> - (void)insertObjects:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)objects atIndexes:(<a class="code" href="class_c_p_index_set.html" title="A collection of unique integers.">CPIndexSet</a>)indexes
<a name="l00956"></a>00956 {
<a name="l00957"></a>00957     var indexesCount = [indexes <a class="code" href="class_c_p_index_set.html#a837688ed946ca09c66595dfa30345d03">count</a>],
<a name="l00958"></a>00958         objectsCount = [objects <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>];
<a name="l00959"></a>00959     
<a name="l00960"></a>00960     <span class="keywordflow">if</span>(indexesCount !== objectsCount)
<a name="l00961"></a>00961         [<a class="code" href="class_c_p_exception.html" title="Used to implement exception handling (creating &amp;amp; raising).">CPException</a> <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">raise</a>:CPRangeException <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">reason</a>:&quot;the counts of the passed-in array (&quot; + objectsCount + &quot;) and index set (&quot; + indexesCount + &quot;) must be identical.&quot;];
<a name="l00962"></a>00962     
<a name="l00963"></a>00963     var lastIndex = [indexes <a class="code" href="class_c_p_index_set.html#a2a6418c6d61b8d5d993c2e2572935758">lastIndex</a>];
<a name="l00964"></a>00964     
<a name="l00965"></a>00965     <span class="keywordflow">if</span>(lastIndex &gt;= [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>] + indexesCount)
<a name="l00966"></a>00966         [<a class="code" href="class_c_p_exception.html" title="Used to implement exception handling (creating &amp;amp; raising).">CPException</a> <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">raise</a>:CPRangeException <a class="code" href="class_c_p_exception.html#ac8f34bd11868822e26a7b952810128b8">reason</a>:&quot;the last index (&quot; + lastIndex + &quot;) must be less than the sum of the original count (&quot; + [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>] + &quot;) and the insertion count (&quot; + indexesCount + &quot;).&quot;];    
<a name="l00967"></a>00967     
<a name="l00968"></a>00968     var index = 0,
<a name="l00969"></a>00969         currentIndex = [indexes <a class="code" href="class_c_p_index_set.html#abc895f4b5df7bdaf090161db6b234b73">firstIndex</a>];
<a name="l00970"></a>00970  
<a name="l00971"></a>00971     <span class="keywordflow">for</span> (; index &lt; objectsCount; ++index, currentIndex = [indexes <a class="code" href="class_c_p_index_set.html#a3f66583eea02c42c2b14e53daf697559">indexGreaterThanIndex</a>:currentIndex])
<a name="l00972"></a>00972         [<span class="keyword">self</span> insertObject:objects[index] atIndex:currentIndex];
<a name="l00973"></a>00973 }
<a name="l00974"></a>00974 
<a name="l00980"></a><a class="code" href="class_c_p_array.html#afd2fe2f3757f436f47814672d844b65f">00980</a> - (void)replaceObjectAtIndex:(<span class="keywordtype">int</span>)anIndex withObject:(<span class="keywordtype">id</span>)anObject
<a name="l00981"></a>00981 {
<a name="l00982"></a>00982     <span class="keyword">self</span>[anIndex] = anObject;
<a name="l00983"></a>00983 }
<a name="l00984"></a>00984 
<a name="l00991"></a><a class="code" href="class_c_p_array.html#a0de32a099cc5149ff2929cedab69058c">00991</a> - (void)replaceObjectsAtIndexes:(<a class="code" href="class_c_p_index_set.html" title="A collection of unique integers.">CPIndexSet</a>)anIndexSet withObjects:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)objects
<a name="l00992"></a>00992 {
<a name="l00993"></a>00993     var i = 0, 
<a name="l00994"></a>00994         index = [anIndexSet <a class="code" href="class_c_p_index_set.html#abc895f4b5df7bdaf090161db6b234b73">firstIndex</a>];
<a name="l00995"></a>00995    
<a name="l00996"></a>00996     <span class="keywordflow">while</span>(index != <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>)
<a name="l00997"></a>00997     {
<a name="l00998"></a>00998         [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#afd2fe2f3757f436f47814672d844b65f">replaceObjectAtIndex</a>:index <a class="code" href="class_c_p_array.html#afd2fe2f3757f436f47814672d844b65f">withObject</a>:objects[i++]];
<a name="l00999"></a>00999         index = [anIndexSet <a class="code" href="class_c_p_index_set.html#a3f66583eea02c42c2b14e53daf697559">indexGreaterThanIndex</a>:index];
<a name="l01000"></a>01000     }
<a name="l01001"></a>01001 }
<a name="l01002"></a>01002 
<a name="l01011"></a><a class="code" href="class_c_p_array.html#aa546e609cc3a30e17dc070b259bdcf8d">01011</a> - (void)replaceObjectsInRange:(CPRange)aRange withObjectsFromArray:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)anArray range:(CPRange)otherRange
<a name="l01012"></a>01012 {
<a name="l01013"></a>01013     <span class="keywordflow">if</span> (!otherRange.location &amp;&amp; otherRange.length == [anArray <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>])
<a name="l01014"></a>01014         [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#ad7ef1510fc5e9d921495125645c43bf9">replaceObjectsInRange</a>:aRange <a class="code" href="class_c_p_array.html#ad7ef1510fc5e9d921495125645c43bf9">withObjectsFromArray</a>:anArray];
<a name="l01015"></a>01015     <span class="keywordflow">else</span>
<a name="l01016"></a>01016         splice.apply(<span class="keyword">self</span>, [aRange.location, aRange.length].concat([anArray subarrayWithRange:otherRange]));
<a name="l01017"></a>01017 }
<a name="l01018"></a>01018 
<a name="l01026"></a><a class="code" href="class_c_p_array.html#ad7ef1510fc5e9d921495125645c43bf9">01026</a> - (void)replaceObjectsInRange:(CPRange)aRange withObjectsFromArray:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)anArray
<a name="l01027"></a>01027 {
<a name="l01028"></a>01028     splice.apply(<span class="keyword">self</span>, [aRange.location, aRange.length].concat(anArray));
<a name="l01029"></a>01029 }
<a name="l01030"></a>01030 
<a name="l01035"></a><a class="code" href="class_c_p_array.html#a0d51d99c720b9c6c91d3edd8be706194">01035</a> - (void)setArray:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)anArray
<a name="l01036"></a>01036 {
<a name="l01037"></a>01037     <span class="keywordflow">if</span>(<span class="keyword">self</span> == anArray) <span class="keywordflow">return</span>;
<a name="l01038"></a>01038     
<a name="l01039"></a>01039     splice.apply(<span class="keyword">self</span>, [0, length].concat(anArray));
<a name="l01040"></a>01040 }
<a name="l01041"></a>01041 
<a name="l01042"></a>01042 <span class="comment">// Removing Objects</span>
<a name="l01046"></a><a class="code" href="class_c_p_array.html#a51d42cbcb7fe44e0bfc8782e26a15f95">01046</a> <span class="comment"></span>- (void)<a class="code" href="class_c_p_array.html#a51d42cbcb7fe44e0bfc8782e26a15f95">removeAllObjects</a>
<a name="l01047"></a>01047 {
<a name="l01048"></a>01048     splice(0, length);
<a name="l01049"></a>01049 }
<a name="l01050"></a>01050 
<a name="l01054"></a><a class="code" href="class_c_p_array.html#a9c74e529c9a3aedec8f3c4e4e0bd95ab">01054</a> - (void)<a class="code" href="class_c_p_array.html#a9c74e529c9a3aedec8f3c4e4e0bd95ab">removeLastObject</a>
<a name="l01055"></a>01055 {
<a name="l01056"></a>01056     pop();
<a name="l01057"></a>01057 }
<a name="l01058"></a>01058 
<a name="l01063"></a><a class="code" href="class_c_p_array.html#a72b71769509e8e5191092dba538a973e">01063</a> - (void)removeObject:(<span class="keywordtype">id</span>)anObject
<a name="l01064"></a>01064 {
<a name="l01065"></a>01065     [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#a0f156ca1f8e4253e0cedbfb1dd9a929d">removeObject</a>:anObject <a class="code" href="class_c_p_array.html#a0f156ca1f8e4253e0cedbfb1dd9a929d">inRange</a>:CPMakeRange(0, length)];
<a name="l01066"></a>01066 }
<a name="l01067"></a>01067 
<a name="l01073"></a><a class="code" href="class_c_p_array.html#a0f156ca1f8e4253e0cedbfb1dd9a929d">01073</a> - (void)removeObject:(<span class="keywordtype">id</span>)anObject inRange:(CPRange)aRange
<a name="l01074"></a>01074 {
<a name="l01075"></a>01075     var index;
<a name="l01076"></a>01076     
<a name="l01077"></a>01077     <span class="keywordflow">while</span> ((index = [<span class="keyword">self</span> indexOfObject:anObject inRange:aRange]) != <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>)
<a name="l01078"></a>01078     {
<a name="l01079"></a>01079         [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#ab91e21ea899f0ef5b395dd5e222d24a1">removeObjectAtIndex</a>:index];
<a name="l01080"></a>01080         aRange = <a class="code" href="group__foundation.html#ga75c00938ebca2b401aacd063802fdde4">CPIntersectionRange</a>(<a class="code" href="group__foundation.html#ga377fec0972facd19d72b8abcffcdb362">CPMakeRange</a>(index, length - index), aRange);
<a name="l01081"></a>01081     }
<a name="l01082"></a>01082 }
<a name="l01083"></a>01083 
<a name="l01088"></a><a class="code" href="class_c_p_array.html#ab91e21ea899f0ef5b395dd5e222d24a1">01088</a> - (void)removeObjectAtIndex:(<span class="keywordtype">int</span>)anIndex
<a name="l01089"></a>01089 {
<a name="l01090"></a>01090     splice(anIndex, 1);
<a name="l01091"></a>01091 }
<a name="l01092"></a>01092 
<a name="l01097"></a><a class="code" href="class_c_p_array.html#af68b3a09de33332d6a9426080bdbb529">01097</a> - (void)removeObjectsAtIndexes:(<a class="code" href="class_c_p_index_set.html" title="A collection of unique integers.">CPIndexSet</a>)anIndexSet
<a name="l01098"></a>01098 {
<a name="l01099"></a>01099     var index = [anIndexSet <a class="code" href="class_c_p_index_set.html#a2a6418c6d61b8d5d993c2e2572935758">lastIndex</a>];
<a name="l01100"></a>01100    
<a name="l01101"></a>01101     <span class="keywordflow">while</span> (index != <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>)
<a name="l01102"></a>01102     {
<a name="l01103"></a>01103         [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#ab91e21ea899f0ef5b395dd5e222d24a1">removeObjectAtIndex</a>:index];
<a name="l01104"></a>01104         index = [anIndexSet <a class="code" href="class_c_p_index_set.html#a33a225a176df0cd6fc0baca73c04ad8c">indexLessThanIndex</a>:index];
<a name="l01105"></a>01105     }
<a name="l01106"></a>01106 }
<a name="l01107"></a>01107 
<a name="l01113"></a><a class="code" href="class_c_p_array.html#ae490be8c6e78e8f5c350dce9e46e91b3">01113</a> - (void)removeObjectIdenticalTo:(<span class="keywordtype">id</span>)anObject
<a name="l01114"></a>01114 {
<a name="l01115"></a>01115     [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#a51a42557fd5e6afe0aa6d8f8b10a8492">removeObjectIdenticalTo</a>:anObject <a class="code" href="class_c_p_array.html#a51a42557fd5e6afe0aa6d8f8b10a8492">inRange</a>:CPMakeRange(0, [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>])];
<a name="l01116"></a>01116 }
<a name="l01117"></a>01117 
<a name="l01125"></a><a class="code" href="class_c_p_array.html#a51a42557fd5e6afe0aa6d8f8b10a8492">01125</a> - (void)removeObjectIdenticalTo:(<span class="keywordtype">id</span>)anObject inRange:(CPRange)aRange
<a name="l01126"></a>01126 {
<a name="l01127"></a>01127     var index,
<a name="l01128"></a>01128         <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>];
<a name="l01129"></a>01129     
<a name="l01130"></a>01130     <span class="keywordflow">while</span> ((index = [<span class="keyword">self</span> indexOfObjectIdenticalTo:anObject inRange:aRange]) !== <a class="code" href="_c_p_obj_j_runtime_8j.html#a84e3be579b365cc2c1559e1a1f469238">CPNotFound</a>)
<a name="l01131"></a>01131     {
<a name="l01132"></a>01132         [<span class="keyword">self</span> <a class="code" href="class_c_p_array.html#ab91e21ea899f0ef5b395dd5e222d24a1">removeObjectAtIndex</a>:index];
<a name="l01133"></a>01133         aRange = <a class="code" href="group__foundation.html#ga75c00938ebca2b401aacd063802fdde4">CPIntersectionRange</a>(<a class="code" href="group__foundation.html#ga377fec0972facd19d72b8abcffcdb362">CPMakeRange</a>(index, (--<a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>) - index), aRange);
<a name="l01134"></a>01134     }
<a name="l01135"></a>01135 }
<a name="l01136"></a>01136 
<a name="l01141"></a><a class="code" href="class_c_p_array.html#a66f50174832a030c5362b198deb22f11">01141</a> - (void)removeObjectsInArray:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)anArray
<a name="l01142"></a>01142 {
<a name="l01143"></a>01143     var index = 0,
<a name="l01144"></a>01144         <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = [anArray <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>];
<a name="l01145"></a>01145         
<a name="l01146"></a>01146     <span class="keywordflow">for</span> (; index &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>; ++index)
<a name="l01147"></a>01147         [<span class="keyword">self</span> removeObject:anArray[index]];
<a name="l01148"></a>01148 }
<a name="l01149"></a>01149 
<a name="l01154"></a><a class="code" href="class_c_p_array.html#a53d980369f09c19cb0befa76bd9aee5f">01154</a> - (void)removeObjectsInRange:(CPRange)aRange
<a name="l01155"></a>01155 {
<a name="l01156"></a>01156     splice(aRange.location, aRange.length);
<a name="l01157"></a>01157 }
<a name="l01158"></a>01158 
<a name="l01159"></a>01159 <span class="comment">// Rearranging objects</span>
<a name="l01165"></a><a class="code" href="class_c_p_array.html#a7b50cce936745dfb2257e9b213f33442">01165</a> <span class="comment"></span>- (void)exchangeObjectAtIndex:(<span class="keywordtype">unsigned</span>)anIndex withObjectAtIndex:(<span class="keywordtype">unsigned</span>)otherIndex
<a name="l01166"></a>01166 {
<a name="l01167"></a>01167     var temporary = <span class="keyword">self</span>[anIndex];
<a name="l01168"></a>01168     <span class="keyword">self</span>[anIndex] = <span class="keyword">self</span>[otherIndex];
<a name="l01169"></a>01169     <span class="keyword">self</span>[otherIndex] = temporary;
<a name="l01170"></a>01170 }
<a name="l01171"></a>01171 
<a name="l01172"></a><a class="code" href="class_c_p_array.html#afe2fbd535a55c5d4a574bd84b4f4ee76">01172</a> - (<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)sortUsingDescriptors:(<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>)descriptors
<a name="l01173"></a>01173 {
<a name="l01174"></a>01174     sort(function(lhs, rhs)
<a name="l01175"></a>01175     {
<a name="l01176"></a>01176         var i = 0,
<a name="l01177"></a>01177             <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a> = [descriptors <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>],
<a name="l01178"></a>01178             result = <a class="code" href="_c_p_obj_j_runtime_8j.html#af6563f83ad093188bcbdba78aa1848c5">CPOrderedSame</a>;
<a name="l01179"></a>01179         
<a name="l01180"></a>01180         <span class="keywordflow">while</span>(i &lt; <a class="code" href="class_c_p_array.html#ae8abed7c67002d9a883005aa40e4fb55">count</a>)
<a name="l01181"></a>01181             <span class="keywordflow">if</span>((result = [descriptors[i++] compareObject:lhs withObject:rhs]) != <a class="code" href="_c_p_obj_j_runtime_8j.html#af6563f83ad093188bcbdba78aa1848c5">CPOrderedSame</a>)
<a name="l01182"></a>01182                 <span class="keywordflow">return</span> result;
<a name="l01183"></a>01183         
<a name="l01184"></a>01184         <span class="keywordflow">return</span> result;
<a name="l01185"></a>01185     });
<a name="l01186"></a>01186 }
<a name="l01187"></a>01187 
<a name="l01193"></a><a class="code" href="class_c_p_array.html#a95828241c03e5dbe990b6bb5dcbec2d3">01193</a> - (void)sortUsingFunction:(Function)aFunction context:(<span class="keywordtype">id</span>)aContext
<a name="l01194"></a>01194 {
<a name="l01195"></a>01195     sort(function(lhs, rhs) { <span class="keywordflow">return</span> aFunction(lhs, rhs, aContext); });
<a name="l01196"></a>01196 }
<a name="l01197"></a>01197 
<a name="l01202"></a><a class="code" href="class_c_p_array.html#a3bba8c85515bcb01637a928367568013">01202</a> - (void)sortUsingSelector:(<span class="keywordtype">SEL</span>)aSelector
<a name="l01203"></a>01203 {
<a name="l01204"></a>01204     sort(function(lhs, rhs) { <span class="keywordflow">return</span> objj_msgSend(lhs, aSelector, rhs); });
<a name="l01205"></a>01205 }
<a name="l01206"></a>01206 
<a name="l01207"></a>01207 <span class="keyword">@end</span>
<a name="l01208"></a>01208 
<a name="l01209"></a>01209 <span class="keyword">@implementation </span><a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a> (CPCoding)
<a name="l01210"></a>01210 
<a name="l01211"></a><a class="code" href="class_c_p_array.html#a91d29c1ec46450a854191196682752dc">01211</a> - (id)initWithCoder:(<a class="code" href="class_c_p_coder.html" title="Defines methods for use when archiving &amp;amp; restoring (enc/decoding).">CPCoder</a>)aCoder
<a name="l01212"></a>01212 {
<a name="l01213"></a>01213     <span class="keywordflow">return</span> [aCoder decodeObjectForKey:@&quot;CP.objects&quot;];
<a name="l01214"></a>01214 }
<a name="l01215"></a>01215 
<a name="l01216"></a><a class="code" href="class_c_p_array.html#a57a46b9aa8e35955c60045878370df18">01216</a> - (void)encodeWithCoder:(<a class="code" href="class_c_p_coder.html" title="Defines methods for use when archiving &amp;amp; restoring (enc/decoding).">CPCoder</a>)aCoder
<a name="l01217"></a>01217 {
<a name="l01218"></a>01218     [aCoder _encodeArrayOfObjects:self forKey:@&quot;CP.objects&quot;];
<a name="l01219"></a>01219 }
<a name="l01220"></a>01220 
<a name="l01221"></a>01221 <span class="keyword">@end</span>
<a name="l01222"></a>01222 
<a name="l01231"></a><a class="code" href="class_c_p_mutable_array.html">01231</a> <span class="keyword">@implementation </span><a class="code" href="class_c_p_mutable_array.html">CPMutableArray</a> : <a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>
<a name="l01232"></a>01232 
<a name="l01233"></a>01233 @end
<a name="l01234"></a>01234 
<a name="l01235"></a><a class="code" href="_c_p_array_8j.html#a702f174ccd5ff8e1139f8657a0bba6fd">01235</a> Array.prototype.<a class="code" href="_c_p_array_8j.html#a702f174ccd5ff8e1139f8657a0bba6fd">isa</a> = <a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a>;
<a name="l01236"></a>01236 [<a class="code" href="class_c_p_array.html" title="A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript...">CPArray</a> initialize];
<a name="l01237"></a>01237 
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated on Tue Apr 6 10:32:56 2010 for Cappuccino API by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>

<!-- Mirrored from cappuccino.org/learn/documentation/_c_p_array_8j_source.html by HTTrack Website Copier/3.x [XR&CO'2006], Mon, 20 Sep 2010 02:19:29 GMT -->
</html>