예제 #1
0
 /* 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
                       )));
 }
예제 #2
0
 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);
         });
     }));
 }
예제 #3
0
 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);
             }
         });
     }));
 }
예제 #4
0
 rIter <A>(this ReadOnlyLinkedList <A> list)
 {
     return(list.iter(true));
 }
예제 #5
0
 public ObservableReadOnlyLinkedListQueue()
 {
     buffer     = new LinkedList <A>();
     collection = new ReadOnlyLinkedList <A>(buffer);
 }
예제 #6
0
 public static bool isEmpty <A>(this ReadOnlyLinkedList <A> list)
 {
     return(list.Count == 0);
 }
예제 #7
0
 public static bool isEmpty <A>(this ReadOnlyLinkedList <A> list) => list.Count == 0;