1 /** 2 Copyright: Copyright (c) 2018, Joakim Brännström. All rights reserved. 3 License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) 4 Author: Joakim Brännström (joakim.brannstrom@gmx.com) 5 6 Range API for various data structures. 7 */ 8 module datacat.range; 9 10 /// Range API for an `Iterator`. 11 struct IteratorRange(T) { 12 private { 13 T* iter; 14 bool lastChange = true; 15 } 16 17 bool front() { 18 assert(!empty, "Can't get front of an empty range"); 19 return lastChange; 20 } 21 22 void popFront() { 23 assert(!empty, "Can't pop front of an empty range"); 24 lastChange = iter.changed; 25 } 26 27 bool empty() { 28 return !lastChange; 29 } 30 }