GitHub PullRequestReviewCommentEvent at 2014-11-11 18:51:09
Repository: bytebuffer-collections
Actor: fjy
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/metamx/bytebuffer-collections/pulls/comments/20170919","id":20170919,"diff_hunk":"@@ -0,0 +1,203 @@\n+package com.metamx.collections;\n+\n+import com.google.common.base.Throwables;\n+import com.google.common.collect.Sets;\n+import com.metamx.collections.bitmap.MutableBitmap;\n+import org.roaringbitmap.IntIterator;\n+\n+import java.util.Collection;\n+import java.util.Iterator;\n+import java.util.Set;\n+\n+/**\n+ *\n+ */\n+public class IntegerSet implements Set<Integer>\n+{\n+  private final MutableBitmap mutableBitmap;\n+  private IntegerSet(MutableBitmap mutableBitmap){\n+    this.mutableBitmap = mutableBitmap;\n+  }\n+  public static IntegerSet wrap(MutableBitmap mutableBitmap){\n+    return new IntegerSet(mutableBitmap);\n+  }\n+\n+  @Override\n+  public int size()\n+  {\n+    return this.mutableBitmap.size();\n+  }\n+\n+  @Override\n+  public boolean isEmpty()\n+  {\n+    return this.mutableBitmap.isEmpty();\n+  }\n+\n+\n+  public static class BitSetIterator implements Iterator<Integer> {\n+    private final IntIterator intIt;\n+    private final MutableBitmap bitSet;\n+    private Integer prior = null;\n+    public BitSetIterator(MutableBitmap bitSet){\n+      this.intIt = bitSet.iterator();\n+      this.bitSet = bitSet;\n+    }\n+    private int pos = 0;\n+    @Override\n+    public boolean hasNext()\n+    {\n+      return intIt.hasNext();\n+    }\n+\n+    @Override\n+    public Integer next()\n+    {\n+      prior = intIt.next();\n+      return prior;\n+    }\n+\n+    @Override\n+    public void remove()\n+    {\n+      bitSet.remove(prior);\n+    }\n+  }\n+\n+  @Override\n+  public boolean contains(Object o)\n+  {\n+    if(o instanceof Integer) {\n+      return mutableBitmap.get((Integer) o);\n+    }else if (o instanceof Long){\n+      return this.contains(((Long) o).intValue());\n+    }\n+    return false;\n+  }\n+\n+  @Override\n+  public Iterator<Integer> iterator()\n+  {\n+    return new BitSetIterator(mutableBitmap);\n+  }\n+\n+  @Override\n+  public Object[] toArray()\n+  {\n+    Integer[] retval = new Integer[mutableBitmap.size()];\n+    int pos = 0;\n+    for(Integer i : this){\n+      retval[pos++] = i;\n+    }\n+    return retval;\n+  }\n+\n+  @Override\n+  public <T> T[] toArray(T[] a)\n+  {\n+    return Sets.newHashSet(this).toArray(a);\n+  }\n+\n+  @Override\n+  public boolean add(Integer integer)\n+  {\n+    if(null == integer){\n+      throw new NullPointerException(\"BitSet cannot contain null values\");\n+    }\n+    if(integer < 0){\n+      throw new IllegalArgumentException(\"Only positive integers or zero can be added\");\n+    }\n+    boolean isSet = mutableBitmap.get(integer);\n+    mutableBitmap.add(integer.intValue());\n+    return !isSet;\n+  }\n+\n+  @Override\n+  public boolean remove(Object o)\n+  {\n+    if(o == null){\n+      throw new NullPointerException(\"BitSet cannot contain null values\");\n+    }\n+    if(o instanceof Integer) {\n+      Integer integer = (Integer) o;\n+      boolean isSet = mutableBitmap.get(integer);\n+      mutableBitmap.remove(integer);\n+      return isSet;\n+    }else{\n+      throw new ClassCastException(\"Cannot remove non Integer from integer BitSet\");\n+    }\n+  }\n+\n+  @Override\n+  public boolean containsAll(Collection<?> c)\n+  {\n+    Iterator<?> it = c.iterator();\n+    while(it.hasNext()){\n+      if(!this.contains(it.next())){\n+        return false;\n+      }\n+    }\n+    return true;\n+  }\n+\n+  @Override\n+  public boolean addAll(Collection<? extends Integer> c)\n+  {\n+    boolean setChanged=false;\n+    for(Integer i : c){\n+      if(!this.contains(i)) {\n+        setChanged = true;\n+        this.add(i);\n+      }\n+    }\n+    return setChanged;\n+  }\n+\n+  @Override\n+  public boolean retainAll(Collection<?> c)\n+  {\n+    MutableBitmap otherMap = null;\n+    try {\n+      otherMap = mutableBitmap.getClass().newInstance();","path":"src/main/java/com/metamx/collections/IntegerSet.java","position":161,"original_position":161,"commit_id":"41a529478b061a68e3d6bcdc7c37c4ddc7dd694a","original_commit_id":"41a529478b061a68e3d6bcdc7c37c4ddc7dd694a","user":{"login":"fjy","id":428325,"avatar_url":"https://avatars.githubusercontent.com/u/428325?v=3","gravatar_id":"","url":"https://api.github.com/users/fjy","html_url":"https://github.com/fjy","followers_url":"https://api.github.com/users/fjy/followers","following_url":"https://api.github.com/users/fjy/following{/other_user}","gists_url":"https://api.github.com/users/fjy/gists{/gist_id}","starred_url":"https://api.github.com/users/fjy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fjy/subscriptions","organizations_url":"https://api.github.com/users/fjy/orgs","repos_url":"https://api.github.com/users/fjy/repos","events_url":"https://api.github.com/users/fjy/events{/privacy}","received_events_url":"https://api.github.com/users/fjy/received_events","type":"User","site_admin":false},"body":"Can we build this class with a bitmapFactory and do this?","created_at":"2014-11-11T18:51:09Z","updated_at":"2014-11-11T18:51:09Z","html_url":"https://github.com/metamx/bytebuffer-collections/pull/9#discussion_r20170919","pull_request_url":"https://api.github.com/repos/metamx/bytebuffer-collections/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/metamx/bytebuffer-collections/pulls/comments/20170919"},"html":{"href":"https://github.com/metamx/bytebuffer-collections/pull/9#discussion_r20170919"},"pull_request":{"href":"https://api.github.com/repos/metamx/bytebuffer-collections/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/metamx/bytebuffer-collections/pulls/9","id":23991472,"html_url":"https://github.com/metamx/bytebuffer-collections/pull/9","diff_url":"https://github.com/metamx/bytebuffer-collections/pull/9.diff","patch_url":"https://github.com/metamx/bytebuffer-collections/pull/9.patch","issue_url":"https://api.github.com/repos/metamx/bytebuffer-collections/issues/9","number":9,"state":"open","locked":false,"title":"IntegerSet and WrappedBitSetBitmap","user":{"login":"drcrallen","id":8213081,"avatar_url":"https://avatars.githubusercontent.com/u/8213081?v=3","gravatar_id":"","url":"https://api.github.com/users/drcrallen","html_url":"https://github.com/drcrallen","followers_url":"https://api.github.com/users/drcrallen/followers","following_url":"https://api.github.com/users/drcrallen/following{/other_user}","gists_url":"https://api.github.com/users/drcrallen/gists{/gist_id}","starred_url":"https://api.github.com/users/drcrallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drcrallen/subscriptions","organizations_url":"https://api.github.com/users/drcrallen/orgs","repos_url":"https://api.github.com/users/drcrallen/repos","events_url":"https://api.github.com/users/drcrallen/events{/privacy}","received_events_url":"https://api.github.com/users/drcrallen/received_events","type":"User","site_admin":false},"body":"Adeed IntegerSet\r\n  * IntegerSet implements Set<Integer> and wraps any one of the MutableBitmap types\r\n  * Updated the bitmap types to include a get(int) function to return if that bit is set\r\n\r\nAdded WrappedBitSetBitmap and WrappedImmutableBitSetBitMap\r\n  * Wraps java.util.BitSet with ImmutableBitmap and MutableBitmap interfaces","created_at":"2014-11-06T16:13:07Z","updated_at":"2014-11-11T18:51:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d909edf20ef31f2d473164bc91338d60288f8370","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/metamx/bytebuffer-collections/pulls/9/commits","review_comments_url":"https://api.github.com/repos/metamx/bytebuffer-collections/pulls/9/comments","review_comment_url":"https://api.github.com/repos/metamx/bytebuffer-collections/pulls/comments/{number}","comments_url":"https://api.github.com/repos/metamx/bytebuffer-collections/issues/9/comments","statuses_url":"https://api.github.com/repos/metamx/bytebuffer-collections/statuses/41a529478b061a68e3d6bcdc7c37c4ddc7dd694a","head":{"label":"metamx:intset","ref":"intset","sha":"41a529478b061a68e3d6bcdc7c37c4ddc7dd694a","user":{"login":"metamx","id":299329,"avatar_url":"https://avatars.githubusercontent.com/u/299329?v=3","gravatar_id":"","url":"https://api.github.com/users/metamx","html_url":"https://github.com/metamx","followers_url":"https://api.github.com/users/metamx/followers","following_url":"https://api.github.com/users/metamx/following{/other_user}","gists_url":"https://api.github.com/users/metamx/gists{/gist_id}","starred_url":"https://api.github.com/users/metamx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metamx/subscriptions","organizations_url":"https://api.github.com/users/metamx/orgs","repos_url":"https://api.github.com/users/metamx/repos","events_url":"https://api.github.com/users/metamx/events{/privacy}","received_events_url":"https://api.github.com/users/metamx/received_events","type":"Organization","site_admin":false},"repo":{"id":9795742,"name":"bytebuffer-collections","full_name":"metamx/bytebuffer-collections","owner":{"login":"metamx","id":299329,"avatar_url":"https://avatars.githubusercontent.com/u/299329?v=3","gravatar_id":"","url":"https://api.github.com/users/metamx","html_url":"https://github.com/metamx","followers_url":"https://api.github.com/users/metamx/followers","following_url":"https://api.github.com/users/metamx/following{/other_user}","gists_url":"https://api.github.com/users/metamx/gists{/gist_id}","starred_url":"https://api.github.com/users/metamx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metamx/subscriptions","organizations_url":"https://api.github.com/users/metamx/orgs","repos_url":"https://api.github.com/users/metamx/repos","events_url":"https://api.github.com/users/metamx/events{/privacy}","received_events_url":"https://api.github.com/users/metamx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/metamx/bytebuffer-collections","description":"ByteBuffer collection classes for java and jvm-based languages.","fork":false,"url":"https://api.github.com/repos/metamx/bytebuffer-collections","forks_url":"https://api.github.com/repos/metamx/bytebuffer-collections/forks","keys_url":"https://api.github.com/repos/metamx/bytebuffer-collections/keys{/key_id}","collaborators_url":"https://api.github.com/repos/metamx/bytebuffer-collections/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/metamx/bytebuffer-collections/teams","hooks_url":"https://api.github.com/repos/metamx/bytebuffer-collections/hooks","issue_events_url":"https://api.github.com/repos/metamx/bytebuffer-collections/issues/events{/number}","events_url":"https://api.github.com/repos/metamx/bytebuffer-collections/events","assignees_url":"https://api.github.com/repos/metamx/bytebuffer-collections/assignees{/user}","branches_url":"https://api.github.com/repos/metamx/bytebuffer-collections/branches{/branch}","tags_url":"https://api.github.com/repos/metamx/bytebuffer-collections/tags","blobs_url":"https://api.github.com/repos/metamx/bytebuffer-collections/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/metamx/bytebuffer-collections/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/metamx/bytebuffer-collections/git/refs{/sha}","trees_url":"https://api.github.com/repos/metamx/bytebuffer-collections/git/trees{/sha}","statuses_url":"https://api.github.com/repos/metamx/bytebuffer-collections/statuses/{sha}","languages_url":"https://api.github.com/repos/metamx/bytebuffer-collections/languages","stargazers_url":"https://api.github.com/repos/metamx/bytebuffer-collections/stargazers","contributors_url":"https://api.github.com/repos/metamx/bytebuffer-collections/contributors","subscribers_url":"https://api.github.com/repos/metamx/bytebuffer-collections/subscribers","subscription_url":"https://api.github.com/repos/metamx/bytebuffer-collections/subscription","commits_url":"https://api.github.com/repos/metamx/bytebuffer-collections/commits{/sha}","git_commits_url":"https://api.github.com/repos/metamx/bytebuffer-collections/git/commits{/sha}","comments_url":"https://api.github.com/repos/metamx/bytebuffer-collections/comments{/number}","issue_comment_url":"https://api.github.com/repos/metamx/bytebuffer-collections/issues/comments/{number}","contents_url":"https://api.github.com/repos/metamx/bytebuffer-collections/contents/{+path}","compare_url":"https://api.github.com/repos/metamx/bytebuffer-collections/compare/{base}...{head}","merges_url":"https://api.github.com/repos/metamx/bytebuffer-collections/merges","archive_url":"https://api.github.com/repos/metamx/bytebuffer-collections/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/metamx/bytebuffer-collections/downloads","issues_url":"https://api.github.com/repos/metamx/bytebuffer-collections/issues{/number}","pulls_url":"https://api.github.com/repos/metamx/bytebuffer-collections/pulls{/number}","milestones_url":"https://api.github.com/repos/metamx/bytebuffer-collections/milestones{/number}","notifications_url":"https://api.github.com/repos/metamx/bytebuffer-collections/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/metamx/bytebuffer-collections/labels{/name}","releases_url":"https://api.github.com/repos/metamx/bytebuffer-collections/releases{/id}","created_at":"2013-05-01T17:05:44Z","updated_at":"2014-10-30T10:45:43Z","pushed_at":"2014-11-08T00:03:10Z","git_url":"git://github.com/metamx/bytebuffer-collections.git","ssh_url":"git@github.com:metamx/bytebuffer-collections.git","clone_url":"https://github.com/metamx/bytebuffer-collections.git","svn_url":"https://github.com/metamx/bytebuffer-collections","homepage":null,"size":619,"stargazers_count":5,"watchers_count":5,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":3,"forks":3,"open_issues":3,"watchers":5,"default_branch":"master"}},"base":{"label":"metamx:fixup","ref":"fixup","sha":"8971e8629156c18b4757150f96745bdc69a445e8","user":{"login":"metamx","id":299329,"avatar_url":"https://avatars.githubusercontent.com/u/299329?v=3","gravatar_id":"","url":"https://api.github.com/users/metamx","html_url":"https://github.com/metamx","followers_url":"https://api.github.com/users/metamx/followers","following_url":"https://api.github.com/users/metamx/following{/other_user}","gists_url":"https://api.github.com/users/metamx/gists{/gist_id}","starred_url":"https://api.github.com/users/metamx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metamx/subscriptions","organizations_url":"https://api.github.com/users/metamx/orgs","repos_url":"https://api.github.com/users/metamx/repos","events_url":"https://api.github.com/users/metamx/events{/privacy}","received_events_url":"https://api.github.com/users/metamx/received_events","type":"Organization","site_admin":false},"repo":{"id":9795742,"name":"bytebuffer-collections","full_name":"metamx/bytebuffer-collections","owner":{"login":"metamx","id":299329,"avatar_url":"https://avatars.githubusercontent.com/u/299329?v=3","gravatar_id":"","url":"https://api.github.com/users/metamx","html_url":"https://github.com/metamx","followers_url":"https://api.github.com/users/metamx/followers","following_url":"https://api.github.com/users/metamx/following{/other_user}","gists_url":"https://api.github.com/users/metamx/gists{/gist_id}","starred_url":"https://api.github.com/users/metamx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metamx/subscriptions","organizations_url":"https://api.github.com/users/metamx/orgs","repos_url":"https://api.github.com/users/metamx/repos","events_url":"https://api.github.com/users/metamx/events{/privacy}","received_events_url":"https://api.github.com/users/metamx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/metamx/bytebuffer-collections","description":"ByteBuffer collection classes for java and jvm-based languages.","fork":false,"url":"https://api.github.com/repos/metamx/bytebuffer-collections","forks_url":"https://api.github.com/repos/metamx/bytebuffer-collections/forks","keys_url":"https://api.github.com/repos/metamx/bytebuffer-collections/keys{/key_id}","collaborators_url":"https://api.github.com/repos/metamx/bytebuffer-collections/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/metamx/bytebuffer-collections/teams","hooks_url":"https://api.github.com/repos/metamx/bytebuffer-collections/hooks","issue_events_url":"https://api.github.com/repos/metamx/bytebuffer-collections/issues/events{/number}","events_url":"https://api.github.com/repos/metamx/bytebuffer-collections/events","assignees_url":"https://api.github.com/repos/metamx/bytebuffer-collections/assignees{/user}","branches_url":"https://api.github.com/repos/metamx/bytebuffer-collections/branches{/branch}","tags_url":"https://api.github.com/repos/metamx/bytebuffer-collections/tags","blobs_url":"https://api.github.com/repos/metamx/bytebuffer-collections/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/metamx/bytebuffer-collections/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/metamx/bytebuffer-collections/git/refs{/sha}","trees_url":"https://api.github.com/repos/metamx/bytebuffer-collections/git/trees{/sha}","statuses_url":"https://api.github.com/repos/metamx/bytebuffer-collections/statuses/{sha}","languages_url":"https://api.github.com/repos/metamx/bytebuffer-collections/languages","stargazers_url":"https://api.github.com/repos/metamx/bytebuffer-collections/stargazers","contributors_url":"https://api.github.com/repos/metamx/bytebuffer-collections/contributors","subscribers_url":"https://api.github.com/repos/metamx/bytebuffer-collections/subscribers","subscription_url":"https://api.github.com/repos/metamx/bytebuffer-collections/subscription","commits_url":"https://api.github.com/repos/metamx/bytebuffer-collections/commits{/sha}","git_commits_url":"https://api.github.com/repos/metamx/bytebuffer-collections/git/commits{/sha}","comments_url":"https://api.github.com/repos/metamx/bytebuffer-collections/comments{/number}","issue_comment_url":"https://api.github.com/repos/metamx/bytebuffer-collections/issues/comments/{number}","contents_url":"https://api.github.com/repos/metamx/bytebuffer-collections/contents/{+path}","compare_url":"https://api.github.com/repos/metamx/bytebuffer-collections/compare/{base}...{head}","merges_url":"https://api.github.com/repos/metamx/bytebuffer-collections/merges","archive_url":"https://api.github.com/repos/metamx/bytebuffer-collections/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/metamx/bytebuffer-collections/downloads","issues_url":"https://api.github.com/repos/metamx/bytebuffer-collections/issues{/number}","pulls_url":"https://api.github.com/repos/metamx/bytebuffer-collections/pulls{/number}","milestones_url":"https://api.github.com/repos/metamx/bytebuffer-collections/milestones{/number}","notifications_url":"https://api.github.com/repos/metamx/bytebuffer-collections/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/metamx/bytebuffer-collections/labels{/name}","releases_url":"https://api.github.com/repos/metamx/bytebuffer-collections/releases{/id}","created_at":"2013-05-01T17:05:44Z","updated_at":"2014-10-30T10:45:43Z","pushed_at":"2014-11-08T00:03:10Z","git_url":"git://github.com/metamx/bytebuffer-collections.git","ssh_url":"git@github.com:metamx/bytebuffer-collections.git","clone_url":"https://github.com/metamx/bytebuffer-collections.git","svn_url":"https://github.com/metamx/bytebuffer-collections","homepage":null,"size":619,"stargazers_count":5,"watchers_count":5,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":3,"forks":3,"open_issues":3,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/metamx/bytebuffer-collections/pulls/9"},"html":{"href":"https://github.com/metamx/bytebuffer-collections/pull/9"},"issue":{"href":"https://api.github.com/repos/metamx/bytebuffer-collections/issues/9"},"comments":{"href":"https://api.github.com/repos/metamx/bytebuffer-collections/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/metamx/bytebuffer-collections/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/metamx/bytebuffer-collections/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/metamx/bytebuffer-collections/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/metamx/bytebuffer-collections/statuses/41a529478b061a68e3d6bcdc7c37c4ddc7dd694a"}}}}