/* ReadOnlyLinkedList to Iter wrapper. */ public static Iter <A, Tpl <LinkedListNode <A>, int, bool> > iter <A>( this ReadOnlyLinkedList <A> list, bool reverse = false ) { return(llIter(list.Count, F.t( // list node, index, reverse reverse ? list.Last : list.First, reverse ? list.Count - 1 : 0, reverse ))); }
protected O bufferImpl <O> (int size, ObserverBuilder <ReadOnlyLinkedList <A>, O> builder) { return(builder(obs => { var buffer = new LinkedList <A>(); var roFacade = new ReadOnlyLinkedList <A>(buffer); return subscribe(val => { buffer.AddLast(val); if (buffer.Count > size) { buffer.RemoveFirst(); } obs.push(roFacade); }); })); }
protected O timeBufferImpl <O> (float seconds, ObserverBuilder <ReadOnlyLinkedList <Tpl <A, float> >, O> builder) { return(builder(obs => { var buffer = new LinkedList <Tpl <A, float> >(); var roFacade = ReadOnlyLinkedList.a(buffer); return subscribe(val => { buffer.AddLast(F.t(val, Time.time)); var lastTime = buffer.Last.Value._2; if (buffer.First.Value._2 + seconds <= lastTime) { // Remove items which are too old. while (buffer.First.Value._2 + seconds < lastTime) { buffer.RemoveFirst(); } obs.push(roFacade); } }); })); }
rIter <A>(this ReadOnlyLinkedList <A> list) { return(list.iter(true)); }
public ObservableReadOnlyLinkedListQueue() { buffer = new LinkedList <A>(); collection = new ReadOnlyLinkedList <A>(buffer); }
public static bool isEmpty <A>(this ReadOnlyLinkedList <A> list) { return(list.Count == 0); }
public static bool isEmpty <A>(this ReadOnlyLinkedList <A> list) => list.Count == 0;