Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would a binary search be quicker then a linear search in layoutAttributesForElements? #24

Open
stshelton opened this issue Jun 28, 2018 · 0 comments

Comments

@stshelton
Copy link

I was watching the latest WWDC and they had a section called "A Tour of UICollectionView". In this section, the instructor creates a mosaic layout like yours by creating a subclass of UICollectionViewLayout just like TRMosaicLayout. Yet the instructor optimizes the layout for scrolling within the layoutAttributesForElements by changing the method from a linear search to a binary. Binary searches are somewhat new to me, so after rewatching the video and doing some research, I found the collection needs to be sorted to be able to run a binary search. My problem is I get a bit confused on how to create the binary search and if your cachedCellLayoutAttributes are sorted already. In the video the instructor says the cachedCallLayoutAttributes are sorted by there frames minimum y value, yet when i debug cachedCellLayoutAttributes it seems that the there frames minimum y value isn't sorted. If you have any ideas or if its even worth doing in the first place let me know. I'll add video link and specific time of video below.

https://developer.apple.com/videos/play/wwdc2018/225/
Specific time about optimization within layoutAttributesForElements: 25:40 -> 28:00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant