Vertex sequences: indexing and insertion #
Positional access into a vertex sequence via the underlying list, and insertion of a vertex at a given index.
Main definitions #
GetElem (VertexSeq α) ℕ α— index into the visited vertices.VertexSeq.insert— insert a vertex at a position.
insert currently has no lemmas and no clients inside AlgoLib; it is kept as the
one positional editing operation the carrier is expected to offer.
Indexing #
@[implicit_reducible]
insert #
Insert the vertex v at index i, shifting later vertices one position
to the right. If i exceeds w.toList.length, v is appended at the end.
Equations
- (VertexSeq.singleton x_3).insert 0 x✝ = (VertexSeq.singleton x✝).cons x_3
- (VertexSeq.singleton x_3).insert n.succ x✝ = (VertexSeq.singleton x_3).cons x✝
- (q.cons x_3).insert x✝¹ x✝ = if x✝¹ ≤ q.length then (q.insert x✝¹ x✝).cons x_3 else if x✝¹ = q.length + 1 then (q.cons x✝).cons x_3 else (q.cons x_3).cons x✝