{"action":"created","issue":{"url":"https://api.github.com/repos/RoaringBitmap/RoaringBitmap/issues/44","repository_url":"https://api.github.com/repos/RoaringBitmap/RoaringBitmap","labels_url":"https://api.github.com/repos/RoaringBitmap/RoaringBitmap/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/RoaringBitmap/RoaringBitmap/issues/44/comments","events_url":"https://api.github.com/repos/RoaringBitmap/RoaringBitmap/issues/44/events","html_url":"https://github.com/RoaringBitmap/RoaringBitmap/issues/44","id":108976662,"number":44,"title":"Optimize iterators (e.g., in particular over mapped bitmaps)","user":{"login":"lemire","id":391987,"avatar_url":"https://avatars.githubusercontent.com/u/391987?v=3","gravatar_id":"","url":"https://api.github.com/users/lemire","html_url":"https://github.com/lemire","followers_url":"https://api.github.com/users/lemire/followers","following_url":"https://api.github.com/users/lemire/following{/other_user}","gists_url":"https://api.github.com/users/lemire/gists{/gist_id}","starred_url":"https://api.github.com/users/lemire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lemire/subscriptions","organizations_url":"https://api.github.com/users/lemire/orgs","repos_url":"https://api.github.com/users/lemire/repos","events_url":"https://api.github.com/users/lemire/events{/privacy}","received_events_url":"https://api.github.com/users/lemire/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/RoaringBitmap/RoaringBitmap/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/RoaringBitmap/RoaringBitmap/labels/help%20wanted","name":"help wanted","color":"009800"},{"url":"https://api.github.com/repos/RoaringBitmap/RoaringBitmap/labels/performance","name":"performance","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-09-29T22:55:51Z","updated_at":"2016-03-03T01:25:14Z","closed_at":null,"body":"Currently, when iterating over an ImmutableRoaringBitmap, one instantiates object containers and then iterator objects.\r\n\r\nWe could streamline this process by *not* creating the object containers and iterating directly over the original ByteBuffer."},"comment":{"url":"https://api.github.com/repos/RoaringBitmap/RoaringBitmap/issues/comments/191526048","html_url":"https://github.com/RoaringBitmap/RoaringBitmap/issues/44#issuecomment-191526048","issue_url":"https://api.github.com/repos/RoaringBitmap/RoaringBitmap/issues/44","id":191526048,"user":{"login":"lemire","id":391987,"avatar_url":"https://avatars.githubusercontent.com/u/391987?v=3","gravatar_id":"","url":"https://api.github.com/users/lemire","html_url":"https://github.com/lemire","followers_url":"https://api.github.com/users/lemire/followers","following_url":"https://api.github.com/users/lemire/following{/other_user}","gists_url":"https://api.github.com/users/lemire/gists{/gist_id}","starred_url":"https://api.github.com/users/lemire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lemire/subscriptions","organizations_url":"https://api.github.com/users/lemire/orgs","repos_url":"https://api.github.com/users/lemire/repos","events_url":"https://api.github.com/users/lemire/events{/privacy}","received_events_url":"https://api.github.com/users/lemire/received_events","type":"User","site_admin":false},"created_at":"2016-03-03T01:25:14Z","updated_at":"2016-03-03T01:25:14Z","body":"@pwebbitrs \r\n\r\nLet us think about what happens in general when you want to iterate over a data structure made of a series of containers.\r\n\r\nWith an iterator, given how it is currently implemented in this library, you have two layers of iterators. That can't be great. Let us look the code...\r\n\r\nhttps://github.com/RoaringBitmap/RoaringBitmap/blob/master/src/main/java/org/roaringbitmap/RoaringBitmap.java#L73-L81\r\n\r\nThat's obviously a lot of code, including some temporary memory allocations.\r\n\r\nHow would the same code work with a `forEach`? It could _almost_ look like this:\r\n\r\n```\r\n forEach(userfunction) {\r\n   for(Container c) {\r\n     c.forEach(userfunction)\r\n   }\r\n }\r\n```\r\n\r\nIt is still not perfect because MappeableContainer need to be instantiated, and they have an underlying buffer that also needs to be instantiated. But I think it would be better.\r\n"}}