1 // Written in D programming language 2 /** 3 * Copyright: © 2014 DSoftOut 4 * License: Subject to the terms of the MIT license, as written in the included LICENSE file. 5 * Authors: NCrashed <ncrashed@gmail.com> 6 */ 7 module pgator.util.list; 8 9 import std.algorithm; 10 import std.container.dlist; 11 import std.range; 12 13 /// Removes one element from the list 14 /** 15 * NEVER use while iterating the $(B list). 16 */ 17 void removeOne(T)(ref DList!T list, T elem) 18 { 19 auto toRemove = list[].find(elem).take(1); 20 list.linearRemove(toRemove); 21 }