为什么HashSet中的元素无序?

时间:2015-11-30 05:16:38

标签: java hashset unordered

保持Set无序有什么优势?

空间/时间更有效吗?

随机订单以什么方式比插入订单更易于管理?

1 个答案:

答案 0 :(得分:1)

Object.hashCode()HashSet中的元素被排序(分散在Javadoc中)Set。如果您需要保留广告订单的<?php $arr=["one" => [ "key1" => "value1", "key2" => "value2", "key3" => [ "key1" => "value3", "key2" => "value4", "key3" => [ "key1" => "value5", "key2" => "value6", "key3" => "value7", "key4" => "value8", "key5" => "value9" ], "key4" => "value10", "key5" => "value11" ], "key4" => "value12", "key5" => "value13" ]]; file_put_contents('myfile.php', var_export($arr, true)); ,则可以使用LinkedHashSet