@@ -432,93 +432,91 @@ $(SPEC_RUNNABLE_EXAMPLE_RUN
432432
433433$(H2 $(LNAME2 properties, Properties and Operations))
434434
435- $(TABLE_2COLS Associative Array Properties,
436- $(THEAD Property name , Description)
435+ $(TABLE
436+ $(THEAD Name , Description)
437437 $(TROW $(D sizeof), $(ARGS The size of the reference to the associative
438438 array; it is 4 in 32-bit builds and 8 on 64-bit builds.))
439439 $(TROW $(D length), $(ARGS The number of values in the
440440 associative array. Unlike for dynamic arrays, it is read-only.))
441- )
442-
443- $(P There is no built-in `empty` property.
444- Phobos provides an implementation of `empty` in `std.range.primitives`.)
445-
446- $(TABLE_2COLS Associative Array Organizing Operations,
447- $(TROW $(D dup()), Returns `null` If the associative array is `null`;
441+ $(TROW $(D dup()), Returns `null` if the associative array is `null`;
448442 otherwise returns a newly allocated associative array with copies of the keys and values of the associative array.)
449443 $(TROW $(D rehash()), $(ARGS Reorganizes the associative array in place so that lookups
450- are more efficient.))
444+ are more efficient. Calling $(D rehash) is effective when, for example,
445+ the program is done loading up a symbol table and now needs
446+ fast lookups in it. Returns a reference to the reorganized array.))
451447 $(TROW $(D clear()), $(ARGS Removes all keys and values from an associative array.
452448 The array is not rehashed after removal to allow for the existing storage to be reused.
453449 This will affect all references to the same instance and is not equivalent to `destroy(aa)`
454- which only sets the current reference to `null`))
450+ which only sets the current reference to `null`. ))
455451 )
456452
457- $(P Calling $(D rehash) is effective when, for example,
458- the program is done loading up a symbol table and now needs
459- fast lookups in it. Returns a reference to the reorganized array.)
453+ $(NOTE There is no built-in `empty` property.
454+ Phobos provides an implementation of `empty` in $(MREF std,range,primitives).)
455+
456+ $(P See $(MREF1 object) for examples.)
460457
461- $(TABLE_2COLS Associative Array Iteration Operations,
458+ $(H3 $(LNAME2 iteration-ops, Iteration Operations))
459+
460+ $(TABLE
462461 $(THEAD Operation, Description)
463462 $(TROW $(D keys()), $(ARGS Returns a newly allocated dynamic array containing copies of the keys in
464- the associative array in an order that is consistent with `values()` but otherwise unspecified.))
465- $(TROW $(D values()), $(ARGS Returns a newly allocated dynamic arraycontaining copies of the values in
466- the associative array in an order that is consistent with `keys()` but otherwise unspecified.))
467- $(TROW $(D byKey()), $(ARGS Returns a forward range enumerating the keys by reference
468- in an order that is consistent with `byValue()` but otherwise unspecified.
463+ the associative array. The order is consistent with `values()` but otherwise unspecified.))
464+ $(TROW $(D values()), $(ARGS Returns a newly allocated dynamic array containing copies of the values in
465+ the associative array. The order is consistent with `keys()` but otherwise unspecified.))
466+ $(TROW $(D byKey()), $(ARGS Returns a forward range enumerating the keys by reference.
467+ The order is consistent with `byValue()` but otherwise unspecified.$(BR)
469468 $(B Bug:) The keys are provided as mutable, but mutating them is undefined behavior.))
470- $(TROW $(D byValue()), $(ARGS Returns a forward range enumerating the values by reference
471- in an order that is consistent with `byKey()` but otherwise unspecified.))
469+ $(TROW $(D byValue()), $(ARGS Returns a forward range enumerating the values by reference.
470+ The order is consistent with `byKey()` but otherwise unspecified.))
472471 $(TROW $(D byKeyValue()), $(ARGS Returns a forward range enumerating opaque objects that provide a `key` and a `value` property
473- in an unspecified order. The two properties return their result by reference.
474- $(B Bug:) The keys are provided as mutable, but mutating them is undefined behavior.))
472+ in an unspecified order. The two properties return their result by reference.$(BR)
473+ $(B Bug:) The keys are provided as mutable, but mutating them is undefined behavior.$(BR)
474+ **Note:** `byKeyValue()` is not compatible with the $(REF_SHORT Tuple, std,typecons)
475+ type in Phobos. For compatibility with `Tuple`, use $(REF byPair, std,array) instead.)))
475476 )
476477
477478 $(P The order of keys and values returned by
478479 `keys()` and `values()` as well as
479480 `byKey()`, `byValue()`, and `byKeyValue()` is unspecified,
480- but is guaranteed to be consistent to each other
481- as long as the associative array has not been reorganized,
481+ but is guaranteed to be consistent as long as the associative array has not been reorganized,
482482 e.g. by adding or removing keys between the calls.
483483 Associating a new value to an existing key does not reorganize an associative array.
484- Reorganizing an associative array invalidates any present input ranges
484+ Reorganizing an associative array invalidates any input ranges
485485 returned by `byKey()`, `byValue()`, and `byKeyValue()`.)
486486
487- $(P Calling `keys()` and `values()` incurs an allocation unless the associative array is `null` or empty.
487+ $(P Calling `keys()` and `values()` incurs an allocation ( unless the associative array is `null` or empty) .
488488 Use them if you need an independent copy of the keys and/or values;
489489 otherwise consider `byKey()` and `byValue()`.)
490490
491- $(P Note that `byKeyValue()` is not compatible
492- with the $(LINK2 $(ROOT_DIR)phobos/std_typecons.html#.Tuple,`Tuple`)
493- type in Phobos. For compatibility with `Tuple`, use
494- $(LINK2 $(ROOT_DIR)phobos/std_array.html#.byPair,std.array.byPair) instead.)
495-
496- $(P Associative arrays support $(LINK2 $(ROOT_DIR)spec/statement.html#foreach_over_associative_arrays, `foreach`)
491+ $(BEST_PRACTICE Associative arrays support
492+ $(DDSUBLINK spec/statement, foreach_over_associative_arrays, `foreach`)
497493 directly for value iteration and key-value iteration.
498- It is recommended to use `ref` on the key and value variables to avoid unnecessary copies.
494+ Use `ref` on the key and value variables when necessary to avoid unnecessary copies.
499495 For iterating the keys only, use key-value iteration and ignore the value.
500- Use `byKey()`, `byValue()`, or `byKeyValue()` for more elaborate cases such as range algorithms.)
496+ Use `byKey()`, `byValue()`, or `byKeyValue()` for more elaborate cases such as
497+ $(MREF_ALTTEXT range algorithms, std,algorithm).)
501498
502- $(TABLE_2COLS Associative Array Elaborate Lookup Operations,
499+ $(H3 $(LNAME2 lookup-ops, Key Lookup Operations))
500+
501+ $(TABLE
502+ $(THEAD Operation, Description)
503503 $(TROW $(D Value get(Key key, lazy Value defVal)),
504- $(ARGS Looks up $(D key);
505- if it exists, returns corresponding value;
504+ $(ARGS If the key exists, returns corresponding value;
506505 otherwise evaluates and returns $(D defVal) without associating it with $(D key).))
507506 $(TROW $(D ref Value require(Key key, lazy Value value)),
508- $(ARGS Looks up $(D key);
509- if it exists, returns corresponding value by reference;
507+ $(ARGS If the key exists, returns corresponding value by reference;
510508 otherwise evaluates $(D value) and associates it with $(D key) in the associative array,
511509 then returns the newly stored value by reference.))
512510 $(TROW $(D void update(Key key, Creator creator, Updater updater)),
513- $(ARGS Looks up $(D key);
514- if it exists, invokes the `updater(value)` on the value (passed by reference if possible)
515- and then, unless `updater(value)` is `void`, associates the result with the key;
516- otherwise invokes `creator()` and associates the result with `key` in the associative array.))
511+ $(ARGS If the key exists, it calls `updater` with the corresponding value;
512+ if it returns a value, it associates the value with the key.
513+ If the key was not found, it invokes `creator()` and associates the result with the key.))
517514 )
518515
519516 $(P The `update` operation works with any `creator` and `updater` that is invokable as specified.
520- An updater can modify the value in-place if it binds its argument by reference.
521- A `void` returning updater with by-reference parameter is recommended to avoid unnecessary copies.)
517+ `updater` can modify the value in-place if it binds its argument by reference.)
518+
519+ $(BEST_PRACTICE A `void` returning `updater` with a `ref` parameter avoids unnecessary copies.)
522520
523521$(H2 $(LNAME2 examples, Examples))
524522
0 commit comments