Add FastUtil lists for lists of primitives (#29282)
* Add FastUtil lists for lists of primitives * fix: rearranged content
This commit is contained in:
committed by
Randell Dawson
parent
307b0dedb3
commit
080c0ae12b
@ -120,5 +120,16 @@ So when it comes down to choosing between the two - if speed is critical then Ve
|
||||
|
||||
It is important to understand the Big O for methods of data structures. This way, you can choose the most efficient data structure for your program.
|
||||
|
||||
#### More Information
|
||||
## ArrayLists and primitives
|
||||
As mentioned before, ArrayLists cannot hold primitive types, and one has to use their corresponding wrapper classes.
|
||||
However it comes with a cost: every time you put a primitive value in the list, or every time you get a wrapped value from the list and put it into a primitive variable, the value is automatically converted from the wrapper objet to the primitive value or the other way around. This is called boxing and unboxing. To avoid these additionnal (useless) conversions, there is the FastUtil library. They have specialkinds of lists that use directly the primitive types.
|
||||
Here are a few examples:
|
||||
- IntList (and its implementation IntArrayList)
|
||||
- BooleanList (and its implementation BooleanArrayList)
|
||||
- DoubleList (and its implementation DoubleArrayList)
|
||||
- and so on with all 8 primitive java types
|
||||
|
||||
Of course they implement the java.util List interface, so they can be used exactly like usual ArrayLists.
|
||||
|
||||
## More Information
|
||||
- [ArrayList Documentation](https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html)
|
||||
|
Reference in New Issue
Block a user