Probably array is the most popular collection of data. Everyone have used, is using and will use it. If array is sorted, this means you can simplify your life while processing array. I want to share some simple, but effective trick with binary search algorithm.
Imagine you have sequence of N numbers which splits space for N + 1 segments. Two of them on the edges are infinite. For instance, this is fuzzy thermometer.
Showing posts with label TipsAndTricks. Show all posts
Showing posts with label TipsAndTricks. Show all posts
February 25, 2016
February 06, 2016
Android Dev Tips: How to replace Enum by int or String efficiently?
There's a good topic on developer.android.com about how to manage app's memory. I want to touch specific paragraph about enums:
Enums often require more than twice as much memory as static constants. You should strictly avoid using enums on Android.
Lot of developers don't want to follow this rule, saying this is inconvenient, hard to navigate through code, hard to debug, blah-blah-blah...
Android guys want to help developers with this. They provided android.support.annotation package with lot of powerful annotations for Android Studio and Lint. I want to explain more about IntDef and StringDef. There two classes may help to replace enums efficiently for both: performance and convenience.
February 05, 2016
Android Dev Tips - How to get static Application Context from anywhere?
Everyone is facing with the problem of accessing Context instance from methods, which aren't logically linked with Activity or Service.
It may be needed for accessing independent resources, like strings or files from assets folder. Sometimes it may be inconvenient to initialize and keep additional variable with the static context.
There're lot of questions on StackOverflow about this. Today I want to share my experience of handling such kind of problems.
It may be needed for accessing independent resources, like strings or files from assets folder. Sometimes it may be inconvenient to initialize and keep additional variable with the static context.
There're lot of questions on StackOverflow about this. Today I want to share my experience of handling such kind of problems.
Subscribe to:
Posts (Atom)