Reputation: 595
I need to have a fixed size array with the length of 10, consisting of double values as they used as a record so this should have efficient structure.
I wonder if there is any fixed length collection in fastutil or simply I can use a double[10] array instead of fastutil?
Upvotes: 0
Views: 503
Reputation: 18792
Array is the way to go. If you must have a fixed size collection you can create one that is backed by array and its size can not be changed :
Integer[] ints = {0,1,2,3,4,5,6,7,8,9};
List<Integer> listBackedByArray = Arrays.asList(ints); //fixed size list
listBackedByArray.add(10);// will produce UnsupportedOperationException
Upvotes: 2