假设我有一个节点链/列表:
(:node {uid:333})-->(:node {uid:102})-->(:node {uid:155})-->...
我想用另一条节点链替换/替换一个或多个连续节点。
(:node {uid:255})-->(:node {uid:107})
在我看来,实现这一目标的操作数量太多,无法将它们放在单个查询中。
1. input [255,107]
2. create the (255)-->(107)
3. find the place where to insert in the original chain
4. connect this node to (255)-->(107)
5. connect the tail-107 to the original chain (if it does not end)
6. delete the part to be replaced..
问题是,如果它不是单个查询,那么它会变得更加复杂。
你会怎么做?(必须像字符串替换一样工作)
简化它的一个想法是找到链中的位置并使用索引。