public static PrimitiveLongSet AsSet(PrimitiveLongSet set) { PrimitiveLongSet result = Primitive.LongSet(set.Size()); PrimitiveLongIterator iterator = set.GetEnumerator(); while (iterator.HasNext()) { result.Add(iterator.Next()); } return(result); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void convertJavaCollectionToSetOfPrimitives() internal virtual void ConvertJavaCollectionToSetOfPrimitives() { IList <long> longs = new IList <long> { 1L, 4L, 7L }; PrimitiveLongSet longSet = PrimitiveLongCollections.AsSet(longs); assertTrue(longSet.Contains(1L)); assertTrue(longSet.Contains(4L)); assertTrue(longSet.Contains(7L)); assertEquals(3, longSet.Size()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void copyPrimitiveSet() internal virtual void CopyPrimitiveSet() { PrimitiveLongSet longSet = PrimitiveLongCollections.setOf(1L, 3L, 5L); PrimitiveLongSet copySet = PrimitiveLongCollections.AsSet(longSet); assertNotSame(copySet, longSet); assertTrue(copySet.Contains(1L)); assertTrue(copySet.Contains(3L)); assertTrue(copySet.Contains(5L)); assertEquals(3, copySet.Size()); }
private static void AssertQueryResultsMatch(ScoreEntityIterator result, long[] ids) { PrimitiveLongSet set = PrimitiveLongCollections.setOf(ids); while (result.MoveNext()) { long next = result.Current.entityId(); assertTrue(format("Result returned node id %d, expected one of %s", next, Arrays.ToString(ids)), set.Remove(next)); } if (!set.Empty) { IList <long> list = new List <long>(); set.VisitKeys(k => !list.Add(k)); fail("Number of results differ from expected. " + set.Size() + " IDs were not found in the result: " + list); } }