https://kotlinlang.org logo
Title
d

dave08

09/12/2017, 12:30 PM
I need to make an enum for android ApplicationInfo flags:
enum class PackageFlags(val mask: Int) {
	NONE(0), SYSTEM_APP(1), IS_DEBUGGABLE(2), SYSTEM_APP_UPDATED(128), IN_SD_CARD(262144),
	IS_DATA_ONLY(16777216), IS_STOPPED(2097152)
}
e

elect

09/12/2017, 1:46 PM
Take in account that if you use enums intensively and you need performances, you should use `Int`s instead
EnumSet
d

dave08

09/12/2017, 8:41 PM
But I thought the whole point of enumset was for performance with its backing bitwise storage of enums? Whereas regular kotlin enums create a new class for each instance. Or maybe enumset does too when wrapping a kotlin enum?
Unless you mean using Int constants for masks with Int flag storage, which might be less clean...?
e

elect

09/13/2017, 8:03 AM
No, the point of using
EnumSet
is that readability, usability and safety is increased, because the
EnumSet
type explicitely specifies which kind of enumrators expect. But to have this, you pay something in performances (nothing is fastest than using simple `Int`s)
since I had to deal a lot with that, I'm used to have a couple of additional functions with enums to easier the job
d

dave08

09/17/2017, 4:59 PM
Not just a couple!!! Tons! 😮 I guess I got the right person for this 🙂