Bernhard
05/06/2019, 12:57 PMLeoColman
05/06/2019, 12:57 PMAlowaniak
05/06/2019, 12:58 PMBernhard
05/06/2019, 12:59 PMdiesieben07
05/06/2019, 12:59 PMHashSet
there is no defined ordering, so the ordering in the list is not deterministic.Dominaezzz
05/06/2019, 12:59 PMset
is a HashSet<...>
then not really.diesieben07
05/06/2019, 12:59 PMLinkedHashSet
on the other hand will preserve insertion order.diesieben07
05/06/2019, 1:00 PMSortedSet
will preserve a specified ordering.Paulius Ruminas
05/06/2019, 1:03 PMThat depends on what set you are using. If you are using aWhen will the ordering be different in the list copy after usingthere is no defined ordering, so the ordering in the list is not deterministic.HashSet
hashSetOf(1, 2, 3).toList()
?Paulius Ruminas
05/06/2019, 1:04 PMdiesieben07
05/06/2019, 1:04 PMdiesieben07
05/06/2019, 1:04 PMdiesieben07
05/06/2019, 1:04 PMPaulius Ruminas
05/06/2019, 1:06 PMval a = hashSetOf(1, 2 ,3)
assertEquals(a.toList(), a.toList())
diesieben07
05/06/2019, 1:06 PMPaulius Ruminas
05/06/2019, 1:09 PMdiesieben07
05/06/2019, 1:09 PMdiesieben07
05/06/2019, 1:09 PMdiesieben07
05/06/2019, 1:10 PMPaulius Ruminas
05/06/2019, 1:11 PMdiesieben07
05/06/2019, 1:11 PMdiesieben07
05/06/2019, 1:11 PMPaulius Ruminas
05/06/2019, 1:11 PMdiesieben07
05/06/2019, 1:11 PMDominaezzz
05/06/2019, 1:12 PMPaulius Ruminas
05/06/2019, 1:13 PMdiesieben07
05/06/2019, 1:14 PMDominaezzz
05/06/2019, 1:15 PMPaulius Ruminas
05/06/2019, 1:16 PMspand
05/06/2019, 1:16 PMDominaezzz
05/06/2019, 1:17 PMdiesieben07
05/06/2019, 1:18 PMThen you can't rely on anything because you can't predict the future ๐Yes, you can rely on the documented behavior of a class.
LinkedHashSet
for example specifies that it will keep the insertion order. That is not going to change.Paulius Ruminas
05/06/2019, 1:46 PMLeoColman
05/06/2019, 1:47 PMLeoColman
05/06/2019, 1:47 PMthanksforallthefish
05/06/2019, 1:47 PMval a = hashSetOf(1, 2, 3)
a.toList() == a.toList() //always true
however, that can change in future implementation.thanksforallthefish
05/06/2019, 1:48 PMval a = linkedHashSetOf(1,2,3)
a.toList() == a.toList() //always true
will hold in future implementations toothanksforallthefish
05/06/2019, 1:49 PMlinkedHashSetOf
helper, consider the above as pseudo-code)Paulius Ruminas
05/06/2019, 1:49 PMdouble calculations is deterministic as it's always the same, even if impreciseDouble is platform specific so why do you say it is deterministic? If I move my code between platforms it will yield different results.
Paulius Ruminas
05/06/2019, 1:50 PMval a = hashSetOf(1,2,3)
a.toList() == a.toList()
a non-deterministic operation.spand
05/06/2019, 1:53 PMDominaezzz
05/06/2019, 1:53 PMghedeon
05/06/2019, 1:53 PMthanksforallthefish
05/06/2019, 1:54 PMalways true
today, might not be true with future jvms anymore. and I am not talking bugs, I am talking expected behaviourPaulius Ruminas
05/06/2019, 2:25 PM