| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.tree.util; |
| 9 |
|
| 10 |
import net.sf.saxon.Configuration; |
| 11 |
import net.sf.saxon.event.ReceiverOptions; |
| 12 |
import net.sf.saxon.expr.parser.ExplicitLocation; |
| 13 |
import net.sf.saxon.expr.parser.Location; |
| 14 |
import net.sf.saxon.om.*; |
| 15 |
import net.sf.saxon.type.BuiltInAtomicType; |
| 16 |
import net.sf.saxon.type.MissingComponentException; |
| 17 |
import net.sf.saxon.type.SimpleType; |
| 18 |
import org.xml.sax.Attributes; |
| 19 |
|
| 20 |
import java.util.Arrays; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
public class AttributeCollectionImpl implements Attributes, AttributeCollection { |
| 35 |
|
| 36 |
private Configuration config; |
| 37 |
|
| 38 |
|
| 39 |
private NodeName[] names = null; |
| 40 |
private String[] values = null; |
| 41 |
private Location[] locations = null; |
| 42 |
private int[] props = null; |
| 43 |
private int used = 0; |
| 44 |
|
| 45 |
private SimpleType[] types = null; |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
public static AttributeCollectionImpl EMPTY_ATTRIBUTE_COLLECTION = |
| 50 |
new AttributeCollectionImpl((Configuration) null); |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
public AttributeCollectionImpl(Configuration config) { |
| 59 |
this.config = config; |
| 60 |
used = 0; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
public static AttributeCollectionImpl copy( AttributeCollectionImpl atts) { |
| 75 |
if (atts.getLength() == 0) { |
| 76 |
return EMPTY_ATTRIBUTE_COLLECTION; |
| 77 |
} |
| 78 |
AttributeCollectionImpl t = new AttributeCollectionImpl(atts.config); |
| 79 |
t.used = atts.used; |
| 80 |
t.names = new NodeName[atts.used]; |
| 81 |
t.values = new String[atts.used]; |
| 82 |
t.props = new int[atts.used]; |
| 83 |
t.locations = new Location[atts.used]; |
| 84 |
System.arraycopy(atts.names, 0, t.names, 0, atts.used); |
| 85 |
System.arraycopy(atts.values, 0, t.values, 0, atts.used); |
| 86 |
System.arraycopy(atts.props, 0, t.props, 0, atts.used); |
| 87 |
System.arraycopy(atts.locations, 0, t.locations, 0, atts.used); |
| 88 |
if (atts.types != null) { |
| 89 |
t.types = new SimpleType[atts.used]; |
| 90 |
System.arraycopy(atts.types, 0, t.types, 0, atts.used); |
| 91 |
} |
| 92 |
return t; |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
public void addAttribute(NodeName nodeName, SimpleType type, String value, Location locationId, int properties) { |
| 109 |
if (values == null) { |
| 110 |
names = new NodeName[5]; |
| 111 |
values = new String[5]; |
| 112 |
props = new int[5]; |
| 113 |
locations = new Location[5]; |
| 114 |
if (!type.equals(BuiltInAtomicType.UNTYPED_ATOMIC)) { |
| 115 |
types = new SimpleType[5]; |
| 116 |
} |
| 117 |
used = 0; |
| 118 |
} |
| 119 |
if (values.length == used) { |
| 120 |
int newsize = used == 0 ? 5 : used * 2; |
| 121 |
names = Arrays.copyOf(names, newsize); |
| 122 |
values = Arrays.copyOf(values, newsize); |
| 123 |
props = Arrays.copyOf(props, newsize); |
| 124 |
locations = Arrays.copyOf(locations, newsize); |
| 125 |
if (types != null) { |
| 126 |
types = Arrays.copyOf(types, newsize); |
| 127 |
} |
| 128 |
} |
| 129 |
int n = used; |
| 130 |
names[n] = nodeName; |
| 131 |
props[n] = properties; |
| 132 |
locations[n] = locationId.saveLocation(); |
| 133 |
setTypeAnnotation(n, type); |
| 134 |
values[used++] = value; |
| 135 |
} |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
public void setAttribute(int index, NodeName nodeName, SimpleType type, String value, Location locationId, int properties) { |
| 151 |
names[index] = nodeName; |
| 152 |
props[index] = properties; |
| 153 |
locations[index] = locationId; |
| 154 |
setTypeAnnotation(index, type); |
| 155 |
values[index] = value; |
| 156 |
} |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
public void clear() { |
| 165 |
used = 0; |
| 166 |
} |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
public void compact() { |
| 173 |
if (used == 0) { |
| 174 |
props = null; |
| 175 |
values = null; |
| 176 |
} else if (values != null && values.length > used) { |
| 177 |
values = Arrays.copyOf(values, used); |
| 178 |
props = Arrays.copyOf(props, used); |
| 179 |
names = Arrays.copyOf(names, used); |
| 180 |
locations = Arrays.copyOf(locations, used); |
| 181 |
if (types != null) { |
| 182 |
types = Arrays.copyOf(types, used); |
| 183 |
} |
| 184 |
} |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
public int getLength() { |
| 196 |
return values == null ? 0 : used; |
| 197 |
} |
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
public int getFingerprint(int index) { |
| 208 |
if (names == null) { |
| 209 |
return -1; |
| 210 |
} |
| 211 |
if (index < 0 || index >= used || names[index] == null) { |
| 212 |
return -1; |
| 213 |
} |
| 214 |
|
| 215 |
return names[index].obtainFingerprint(config.getNamePool()); |
| 216 |
} |
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
public NodeName getNodeName(int index) { |
| 227 |
if (names == null) { |
| 228 |
return null; |
| 229 |
} |
| 230 |
if (index < 0 || index >= used) { |
| 231 |
return null; |
| 232 |
} |
| 233 |
|
| 234 |
return names[index]; |
| 235 |
} |
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
public SimpleType getTypeAnnotation(int index) { |
| 246 |
if (types == null) { |
| 247 |
return BuiltInAtomicType.UNTYPED_ATOMIC; |
| 248 |
} |
| 249 |
if (index < 0 || index >= used) { |
| 250 |
return BuiltInAtomicType.UNTYPED_ATOMIC; |
| 251 |
} |
| 252 |
|
| 253 |
return types[index]; |
| 254 |
} |
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
public Location getLocation(int index) { |
| 265 |
if (locations == null) { |
| 266 |
return ExplicitLocation.UNKNOWN_LOCATION; |
| 267 |
} |
| 268 |
if (index < 0 || index >= used) { |
| 269 |
return ExplicitLocation.UNKNOWN_LOCATION; |
| 270 |
} |
| 271 |
|
| 272 |
return locations[index]; |
| 273 |
} |
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
public String getSystemId(int index) { |
| 288 |
return getLocation(index).getSystemId(); |
| 289 |
} |
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
public int getLineNumber(int index) { |
| 304 |
return getLocation(index).getLineNumber(); |
| 305 |
} |
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
public int getProperties(int index) { |
| 318 |
if (props == null) { |
| 319 |
return -1; |
| 320 |
} |
| 321 |
if (index < 0 || index >= used) { |
| 322 |
return -1; |
| 323 |
} |
| 324 |
|
| 325 |
return props[index]; |
| 326 |
} |
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
public String getPrefix(int index) { |
| 339 |
if (names == null) { |
| 340 |
return null; |
| 341 |
} |
| 342 |
if (index < 0 || index >= used) { |
| 343 |
return null; |
| 344 |
} |
| 345 |
return names[index].getPrefix(); |
| 346 |
} |
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
public String getQName(int index) { |
| 358 |
if (names == null) { |
| 359 |
return null; |
| 360 |
} |
| 361 |
if (index < 0 || index >= used) { |
| 362 |
return null; |
| 363 |
} |
| 364 |
return names[index].getDisplayName(); |
| 365 |
} |
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
public String getLocalName(int index) { |
| 377 |
if (names == null) { |
| 378 |
return null; |
| 379 |
} |
| 380 |
if (index < 0 || index >= used) { |
| 381 |
return null; |
| 382 |
} |
| 383 |
return names[index].getLocalPart(); |
| 384 |
} |
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
public String getURI(int index) { |
| 396 |
if (names == null) { |
| 397 |
return null; |
| 398 |
} |
| 399 |
if (index < 0 || index >= used) { |
| 400 |
return null; |
| 401 |
} |
| 402 |
return names[index].getURI(); |
| 403 |
} |
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
public String getType(int index) { |
| 420 |
int typeCode = getTypeAnnotation(index).getFingerprint(); |
| 421 |
switch (typeCode) { |
| 422 |
case StandardNames.XS_ID: |
| 423 |
return "ID"; |
| 424 |
case StandardNames.XS_IDREF: |
| 425 |
return "IDREF"; |
| 426 |
case StandardNames.XS_NMTOKEN: |
| 427 |
return "NMTOKEN"; |
| 428 |
case StandardNames.XS_ENTITY: |
| 429 |
return "ENTITY"; |
| 430 |
case StandardNames.XS_IDREFS: |
| 431 |
return "IDREFS"; |
| 432 |
case StandardNames.XS_NMTOKENS: |
| 433 |
return "NMTOKENS"; |
| 434 |
case StandardNames.XS_ENTITIES: |
| 435 |
return "ENTITIES"; |
| 436 |
default: |
| 437 |
return "CDATA"; |
| 438 |
} |
| 439 |
} |
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
public String getType(String uri, String localname) { |
| 451 |
int index = findByName(uri, localname); |
| 452 |
return (index < 0 ? null : getType(index)); |
| 453 |
} |
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
public String getValue(int index) { |
| 465 |
if (values == null) { |
| 466 |
return null; |
| 467 |
} |
| 468 |
if (index < 0 || index >= used) { |
| 469 |
return null; |
| 470 |
} |
| 471 |
return values[index]; |
| 472 |
} |
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
public String getValue(String uri, String localname) { |
| 484 |
int index = findByName(uri, localname); |
| 485 |
return (index < 0 ? null : getValue(index)); |
| 486 |
} |
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
public String getValueByFingerprint(int fingerprint) { |
| 494 |
int index = findByFingerprint(fingerprint); |
| 495 |
return (index < 0 ? null : getValue(index)); |
| 496 |
} |
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
public int getIndex( String qname) { |
| 506 |
if (names == null) { |
| 507 |
return -1; |
| 508 |
} |
| 509 |
if (qname.indexOf(':') < 0) { |
| 510 |
return findByName("", qname); |
| 511 |
} |
| 512 |
|
| 513 |
String[] parts; |
| 514 |
try { |
| 515 |
parts = NameChecker.getQNameParts(qname); |
| 516 |
} catch (QNameException err) { |
| 517 |
return -1; |
| 518 |
} |
| 519 |
String prefix = parts[0]; |
| 520 |
if (prefix.isEmpty()) { |
| 521 |
return findByName("", qname); |
| 522 |
} else { |
| 523 |
String localName = parts[1]; |
| 524 |
for (int i = 0; i < used; i++) { |
| 525 |
if (names[i] != null) { |
| 526 |
String lname = names[i].getLocalPart(); |
| 527 |
String ppref = names[i].getPrefix(); |
| 528 |
if (localName.equals(lname) && prefix.equals(ppref)) { |
| 529 |
return i; |
| 530 |
} |
| 531 |
} |
| 532 |
} |
| 533 |
return -1; |
| 534 |
} |
| 535 |
} |
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
public int getIndex(String uri, String localname) { |
| 546 |
return findByName(uri, localname); |
| 547 |
} |
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
public int getIndexByFingerprint(int fingerprint) { |
| 555 |
return findByFingerprint(fingerprint); |
| 556 |
} |
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
public String getType( String name) { |
| 568 |
int index = getIndex(name); |
| 569 |
return getType(index); |
| 570 |
} |
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
public String getValue( String name) { |
| 583 |
int index = getIndex(name); |
| 584 |
return getValue(index); |
| 585 |
} |
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
public boolean hasAttributeInNamespace(String uri) { |
| 596 |
if (names == null || config == null) { |
| 597 |
return false; |
| 598 |
} |
| 599 |
for (int i = 0; i < used; i++) { |
| 600 |
if (names[i] != null && names[i].hasURI(uri)) { |
| 601 |
return true; |
| 602 |
} |
| 603 |
} |
| 604 |
return false; |
| 605 |
} |
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
private int findByName(String uri, String localName) { |
| 616 |
if (names == null || config == null) { |
| 617 |
return -1; |
| 618 |
} |
| 619 |
for (int i = 0; i < used; i++) { |
| 620 |
if (names[i] != null && names[i].hasURI(uri) && localName.equals(names[i].getLocalPart())) { |
| 621 |
return i; |
| 622 |
} |
| 623 |
} |
| 624 |
return -1; |
| 625 |
} |
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
private int findByFingerprint(int fingerprint) { |
| 635 |
if (names == null || config == null) { |
| 636 |
return -1; |
| 637 |
} |
| 638 |
NamePool pool = config.getNamePool(); |
| 639 |
for (int i = 0; i < used; i++) { |
| 640 |
NodeName nn = names[i]; |
| 641 |
if (nn != null) { |
| 642 |
if (nn.hasFingerprint()) { |
| 643 |
if (nn.getFingerprint() == fingerprint) { |
| 644 |
return i; |
| 645 |
} |
| 646 |
} else { |
| 647 |
if (nn.hasURI(pool.getURI(fingerprint)) && nn.getLocalPart().equals(pool.getLocalName(fingerprint))) { |
| 648 |
return i; |
| 649 |
} |
| 650 |
} |
| 651 |
} |
| 652 |
} |
| 653 |
return -1; |
| 654 |
} |
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
public int findByNodeName( NodeName nodeName) { |
| 664 |
if (props == null || config == null) { |
| 665 |
return -1; |
| 666 |
} |
| 667 |
if (nodeName.hasFingerprint()) { |
| 668 |
return findByFingerprint(nodeName.getFingerprint()); |
| 669 |
} else { |
| 670 |
return findByName(nodeName.getURI(), nodeName.getLocalPart()); |
| 671 |
} |
| 672 |
} |
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
public boolean isId(int index) { |
| 680 |
try { |
| 681 |
return !isDeleted(index) && |
| 682 |
(StandardNames.XML_ID_NAME.equals(names[index]) || |
| 683 |
(getProperties(index) & ReceiverOptions.IS_ID) != 0 || |
| 684 |
getTypeAnnotation(index).isIdType()); |
| 685 |
} catch (MissingComponentException e) { |
| 686 |
return false; |
| 687 |
} |
| 688 |
} |
| 689 |
|
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
public boolean isIdref(int index) { |
| 695 |
try { |
| 696 |
return getTypeAnnotation(index).isIdRefType(); |
| 697 |
} catch (MissingComponentException e) { |
| 698 |
return false; |
| 699 |
} |
| 700 |
} |
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
public void removeAttribute(int index) { |
| 711 |
names[index] = null; |
| 712 |
props[index] = -1; |
| 713 |
values[index] = null; |
| 714 |
locations[index] = null; |
| 715 |
if (types != null) { |
| 716 |
types[index] = null; |
| 717 |
} |
| 718 |
} |
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
public boolean isDeleted(int index) { |
| 728 |
return names[index] == null; |
| 729 |
} |
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
public void renameAttribute(int index, NodeName newName) { |
| 739 |
names[index] = newName; |
| 740 |
if (types != null) { |
| 741 |
types[index] = BuiltInAtomicType.UNTYPED_ATOMIC; |
| 742 |
} |
| 743 |
} |
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
public void replaceAttribute(int index, CharSequence newValue) { |
| 753 |
values[index] = newValue.toString(); |
| 754 |
} |
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
public void setTypeAnnotation(int index, SimpleType type) { |
| 764 |
if (type.equals(BuiltInAtomicType.UNTYPED_ATOMIC)) { |
| 765 |
if (types != null) { |
| 766 |
types[index] = type; |
| 767 |
} |
| 768 |
} else { |
| 769 |
if (types == null) { |
| 770 |
types = new SimpleType[names.length]; |
| 771 |
Arrays.fill(types, BuiltInAtomicType.UNTYPED_ATOMIC); |
| 772 |
types[index] = type; |
| 773 |
} else { |
| 774 |
types[index] = type; |
| 775 |
} |
| 776 |
} |
| 777 |
} |
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
public void swap(int i, int j) { |
| 787 |
NodeName n = names[i]; |
| 788 |
names[i] = names[j]; |
| 789 |
names[j] = n; |
| 790 |
if (types != null) { |
| 791 |
SimpleType s = types[i]; |
| 792 |
types[i] = types[j]; |
| 793 |
types[j] = s; |
| 794 |
} |
| 795 |
String c = values[i]; |
| 796 |
values[i] = values[j]; |
| 797 |
values[j] = c; |
| 798 |
int p = props[i]; |
| 799 |
props[i] = props[j]; |
| 800 |
props[j] = p; |
| 801 |
Location l = locations[i]; |
| 802 |
locations[i] = locations[j]; |
| 803 |
locations[j] = l; |
| 804 |
} |
| 805 |
|
| 806 |
|
| 807 |
} |
| 808 |
|