Inserts an element into a structure-specific position according to class semantics.
Details
insert() is an S3 generic. Required arguments in ... depend on x:
priority_queue:element,priority(optionalname)ordered_sequence:element,key(optionalname)interval_index:element,start,end(optionalname)
This operation is persistent: x is not modified.
Examples
q <- priority_queue("a", "b", priorities = c(2, 1))
insert(q, "c", priority = 3)
#> Unnamed priority_queue with 3 elements.
#> Minimum priority: 1, Maximum priority: 3
#>
#> Elements (by priority):
#>
#> (priority 1)
#> [1] "b"
#>
#> (priority 2)
#> [1] "a"
#>
#> (priority 3)
#> [1] "c"
#>
o <- ordered_sequence("a", "c", keys = c(1, 3))
insert(o, "b", key = 2)
#> Unnamed ordered_sequence with 3 elements.
#>
#> Elements (by key order):
#>
#> [[1]] (key 1)
#> [1] "a"
#>
#> [[2]] (key 2)
#> [1] "b"
#>
#> [[3]] (key 3)
#> [1] "c"
#>
iv <- interval_index("A", "B", start = c(1, 5), end = c(3, 8))
insert(iv, "C", start = 2, end = 6)
#> Unnamed interval_index with 3 elements, default query bounds [start, end).
#>
#> Elements (by interval start order):
#>
#> [[1]] (interval 1 - 3)
#> [1] "A"
#>
#> [[2]] (interval 2 - 6)
#> [1] "C"
#>
#> [[3]] (interval 5 - 8)
#> [1] "B"
#>
