public static void Consume(PrimitiveIntIterator source, System.Action <int> consumer) { while (source.HasNext()) { consumer(source.Next()); } }
public override bool AddAll(PrimitiveIntIterator values) { bool changed = false; while (values.HasNext()) { changed |= HopScotchHashingAlgorithm.Put(Table, _monitor, DEFAULT_HASHING, values.Next(), _valueMarker, this) == null; } return(changed); }
public static ISet <T> MapToSet <T>(PrimitiveIntIterator iterator, System.Func <int, T> map) { ISet <T> set = new HashSet <T>(); while (iterator.HasNext()) { AddUnique(set, map(iterator.Next())); } return(set); }
/// <summary> /// Pulls all items from the {@code iterator} and puts them into a <seealso cref="System.Collections.IList"/>, boxing each int. /// </summary> /// <param name="iterator"> <seealso cref="PrimitiveIntIterator"/> to pull values from. </param> /// <returns> a <seealso cref="System.Collections.IList"/> containing all items. </returns> public static IList <int> ToList(PrimitiveIntIterator iterator) { IList <int> @out = new List <int>(); while (iterator.HasNext()) { @out.Add(iterator.Next()); } return(@out); }
public static long[] AsLongArray(PrimitiveIntCollection values) { long[] array = new long[values.Size()]; PrimitiveIntIterator iterator = values.GetEnumerator(); int i = 0; while (iterator.HasNext()) { array[i++] = iterator.Next(); } return(array); }
public static PrimitiveIntSet AsSet(PrimitiveIntIterator iterator) { PrimitiveIntSet set = Primitive.IntSet(); while (iterator.HasNext()) { int next = iterator.Next(); if (!set.Add(next)) { throw new System.InvalidOperationException("Duplicate " + next + " from " + iterator); } } return(set); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldIterate() internal virtual void ShouldIterate() { // GIVEN PrimitiveIntStack stack = new PrimitiveIntStack(); // WHEN for (int i = 0; i < 7; i++) { stack.Push(i); } // THEN PrimitiveIntIterator iterator = stack.GetEnumerator(); int i = 0; while (iterator.HasNext()) { assertEquals(i++, iterator.Next()); } assertEquals(7, i); }
private static void AssertNextEquals(long expected, PrimitiveIntIterator iterator) { assertTrue(iterator.HasNext(), iterator + " should have had more items"); assertEquals(expected, iterator.Next()); }
private static void AssertNoMoreItems(PrimitiveIntIterator iterator) { assertFalse(iterator.HasNext(), iterator + " should have no more items"); assertThrows(typeof(NoSuchElementException), iterator.next); }