From e32d818873ddd0246ac7f7296462689166bff553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Fri, 21 Jul 2017 01:38:46 +0200 Subject: [PATCH] Add CircularDList.insertAfter. --- source/vibe/internal/list.d | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/vibe/internal/list.d b/source/vibe/internal/list.d index cfc4135..dffe57c 100644 --- a/source/vibe/internal/list.d +++ b/source/vibe/internal/list.d @@ -39,7 +39,16 @@ struct CircularDList(T) pivot.prev = elem; } - void insertFront(T elem) { insertBefore(elem, m_pivot.next); } + void insertAfter(T elem, T pivot) + { + assert(elem.prev is null && elem.next is null); + elem.prev = pivot; + elem.next = pivot.next; + pivot.next.prev = elem; + pivot.next = elem; + } + + void insertFront(T elem) { insertAfter(elem, m_pivot); } void insertBack(T elem) { insertBefore(elem, m_pivot); }