Fuzion Logo
fuzion-lang.dev — The Fuzion Language Portal
»

concat

Sequence.concat

(s Sequence Sequence.T)
 => 
Sequence Sequence.T
[Contains abstract features]
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s

General case: This will perform `as_list.concat_list` in case one of
`Sequence.this` or `s`is not known to be finite (`finite != trit.yet`) or
`s.count` is larger than `count`.

Otherwise, if `Sequence.this` or `s` is empty, the result will be `s` or
`Sequence.this`, respectively.

In all other cases, an instance of `container.expanding_array` will be
created and the elements of `this` and `s` will be added. Note that
`concat` is redefined for `container.expanding_array` to achieve
average `O(1)` performance for repeated concatenation with `s.count < c`
for some constant `c`.

Performance: O(count + s.count) worst case, O(s.count) average case

NOTE: For repeated concatenation `a.concat b` that fall into the general
case the resulting sequence will have iteration performance in `O(n²)`
for `n` concatenation. Explicitly use `container.expanding_array` to
avoid this. This implementation cannot do this automatically since
repeated wrapping of `a` into an `expanding_array` would result
in `O(n²)` performance for the concatenations.
0.094dev (2025-06-18 15:08:51 GIT hash 89cffc23ae669b0898a5564fefbf793fcb8e5ca7 built by fridi@fzen)