{"action":"created","comment":{"url":"https://api.github.com/repos/scala-js/scala-js/pulls/comments/32667755","id":32667755,"diff_hunk":"@@ -0,0 +1,356 @@\n+package java.util\n+\n+import scala.annotation.tailrec\n+\n+class LinkedList[E]() extends AbstractSequentialList[E]\n+    with List[E] with Deque[E] with Cloneable with Serializable {\n+    self =>\n+\n+  def this(c: Collection[_ <: E]) = {\n+    this()\n+    addAll(c)\n+  }\n+\n+  import LinkedList._\n+\n+  var head: Node[Box[E]] = new Node(None)\n+  var last: Node[Box[E]] = new Node(None)\n+\n+  var _size = 0\n+\n+  def getFirst(): E = {\n+    if (_size <= 0)\n+      throw new NoSuchElementException()\n+    else if (head.isEmpty)\n+      last.getValue().get.inner\n+    else\n+      head.getValue().get.inner\n+  }\n+\n+  def getLast(): E = {\n+    if (_size <= 0)\n+      throw new NoSuchElementException()\n+    else if (last.isEmpty)\n+      head.getValue().get.inner\n+    else\n+      last.getValue().get.inner\n+  }\n+\n+  def removeFirst(): E = {\n+    if (_size <= 0) throw new NoSuchElementException()\n+    else {\n+      if (head.isEmpty) {\n+        val oldHead = last.getValue().get.inner\n+        last.remValue()\n+        last.remPrev()\n+        last.remNext()\n+        _size -= 1\n+        oldHead\n+      } else {\n+        val newHead = head.getNext()\n+        val oldHead = head.getValue().get.inner\n+        if (!newHead.isEmpty) {\n+          head = newHead.get\n+          head.remPrev()\n+        } else {\n+          head.remValue()\n+        }\n+        _size -= 1\n+        oldHead\n+      }\n+    }\n+  }\n+\n+  def removeLast(): E = {\n+    if (_size <= 0) throw new NoSuchElementException()\n+    else {\n+      if (last.isEmpty) {\n+        val oldLast = head.getValue().get.inner\n+        head.remValue()\n+        head.remPrev()\n+        head.remNext()\n+        _size -= 1\n+        oldLast\n+      } else {\n+        val newLast = last.getPrev()\n+        val oldLast = last.getValue().get.inner\n+        if (!newLast.isEmpty) {\n+          last = newLast.get\n+          last.remNext()\n+        } else {\n+          last.remValue()\n+        }\n+        _size -= 1\n+        oldLast\n+      }\n+    }\n+  }\n+\n+  def addFirst(e: E): Unit = {\n+    if (head.isEmpty) {\n+      head.setValue(Box(e))\n+      head.remNext()\n+      head.remPrev()\n+    } else if (last.isEmpty) {\n+      last.setValue(head.getValue().get)\n+      last.setPrev(head)\n+      last.remNext()\n+      head.setValue(Box(e))\n+      head.setNext(last)\n+      head.remPrev()\n+    } else {\n+      val node = new Node(Some(Box(e)))\n+      head.setPrev(node)\n+      node.setNext(head)\n+      head = node\n+    }\n+    _size += 1\n+  }\n+\n+  def addLast(e: E): Unit = {\n+    if (last.isEmpty) {\n+      last.setValue(Box(e))\n+    } else if (head.isEmpty) {\n+      head.setValue(last.getValue().get)\n+      head.setNext(last)\n+      head.remPrev()\n+      last.setValue(Box(e))\n+      last.setPrev(head)\n+      last.remNext()\n+    }else {\n+      val node = new Node(Some(Box(e)))\n+      last.setNext(node)\n+      node.setPrev(last)\n+      last = node\n+    }\n+    _size += 1\n+  }\n+\n+  override def contains(o: Any): Boolean = {\n+    val boxed = Box(o.asInstanceOf[E])\n+\n+    @tailrec\n+    def check(n: Node[Box[E]]): Boolean = {\n+      if (n.isEmpty) false else {\n+        if (n.getValue().get.equals(boxed)) true\n+        else if (n.getNext().isEmpty) false\n+        else check(n.getNext().get)\n+      }\n+    }\n+\n+    if (head.getValue().isEmpty)\n+      check(last)\n+    else\n+      check(head)\n+  }\n+\n+  override def size(): Int =\n+    _size\n+\n+  override def add(e: E): Boolean = {\n+    addLast(e)\n+    true\n+  }\n+\n+  override def remove(o: Any): Boolean = {\n+    val boxed = Box(o.asInstanceOf[E])\n+    val iter = listIterator()\n+    var changed = false\n+    while (iter.hasNext()) {\n+      if (Box(iter.next()).equals(boxed)) {\n+        iter.remove()\n+        changed = true\n+      }\n+    }\n+\n+    changed\n+  }\n+\n+  override def addAll(c: Collection[_ <: E]): Boolean = {\n+    val iter = c.iterator\n+    var changed = iter.hasNext()\n+    while (iter.hasNext())\n+      addLast(iter.next())\n+\n+    changed\n+  }\n+\n+  override def clear(): Unit = {\n+    head = new Node(None)\n+    last = new Node(None)\n+    _size = 0\n+  }\n+\n+  override def get(index: Int): E = {\n+    checkIndexInBounds(index)\n+\n+    throw new Exception(\"TBD\")\n+  }\n+\n+  override def set(index: Int, element: E): E = {\n+    add(index, element)\n+    remove(index+1)\n+  }\n+\n+  override def add(index: Int, element: E): Unit = {\n+    checkIndexOnBounds(index)\n+    \n+    throw new Exception(\"TBD\")","path":"javalib/src/main/scala/java/util/LinkedList.scala","position":198,"original_position":198,"commit_id":"29d91c9f7b0a0a1e20a1e2c6be36165d35fad9a9","original_commit_id":"29d91c9f7b0a0a1e20a1e2c6be36165d35fad9a9","user":{"login":"nicolasstucki","id":3648029,"avatar_url":"https://avatars.githubusercontent.com/u/3648029?v=3","gravatar_id":"","url":"https://api.github.com/users/nicolasstucki","html_url":"https://github.com/nicolasstucki","followers_url":"https://api.github.com/users/nicolasstucki/followers","following_url":"https://api.github.com/users/nicolasstucki/following{/other_user}","gists_url":"https://api.github.com/users/nicolasstucki/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolasstucki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolasstucki/subscriptions","organizations_url":"https://api.github.com/users/nicolasstucki/orgs","repos_url":"https://api.github.com/users/nicolasstucki/repos","events_url":"https://api.github.com/users/nicolasstucki/events{/privacy}","received_events_url":"https://api.github.com/users/nicolasstucki/received_events","type":"User","site_admin":false},"body":"You could use the Scala shorthand for that: `???`\r\nWay faster to write ;)","created_at":"2015-06-17T19:56:54Z","updated_at":"2015-06-17T19:56:54Z","html_url":"https://github.com/scala-js/scala-js/pull/1710#discussion_r32667755","pull_request_url":"https://api.github.com/repos/scala-js/scala-js/pulls/1710","_links":{"self":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/comments/32667755"},"html":{"href":"https://github.com/scala-js/scala-js/pull/1710#discussion_r32667755"},"pull_request":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/1710"}}},"pull_request":{"url":"https://api.github.com/repos/scala-js/scala-js/pulls/1710","id":37448854,"html_url":"https://github.com/scala-js/scala-js/pull/1710","diff_url":"https://github.com/scala-js/scala-js/pull/1710.diff","patch_url":"https://github.com/scala-js/scala-js/pull/1710.patch","issue_url":"https://api.github.com/repos/scala-js/scala-js/issues/1710","number":1710,"state":"open","locked":false,"title":"Port java.util.LinkedList.","user":{"login":"andreaTP","id":5792097,"avatar_url":"https://avatars.githubusercontent.com/u/5792097?v=3","gravatar_id":"","url":"https://api.github.com/users/andreaTP","html_url":"https://github.com/andreaTP","followers_url":"https://api.github.com/users/andreaTP/followers","following_url":"https://api.github.com/users/andreaTP/following{/other_user}","gists_url":"https://api.github.com/users/andreaTP/gists{/gist_id}","starred_url":"https://api.github.com/users/andreaTP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreaTP/subscriptions","organizations_url":"https://api.github.com/users/andreaTP/orgs","repos_url":"https://api.github.com/users/andreaTP/repos","events_url":"https://api.github.com/users/andreaTP/events{/privacy}","received_events_url":"https://api.github.com/users/andreaTP/received_events","type":"User","site_admin":false},"body":"Hope to have suggestions especially on the listIterator... it's a bit wired but looks working as expected.","created_at":"2015-06-11T10:22:35Z","updated_at":"2015-06-17T19:56:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dbc2014f625d18ac7c8bda0ea1a36c01993537df","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scala-js/scala-js/pulls/1710/commits","review_comments_url":"https://api.github.com/repos/scala-js/scala-js/pulls/1710/comments","review_comment_url":"https://api.github.com/repos/scala-js/scala-js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scala-js/scala-js/issues/1710/comments","statuses_url":"https://api.github.com/repos/scala-js/scala-js/statuses/29d91c9f7b0a0a1e20a1e2c6be36165d35fad9a9","head":{"label":"andreaTP:linkedlist","ref":"linkedlist","sha":"29d91c9f7b0a0a1e20a1e2c6be36165d35fad9a9","user":{"login":"andreaTP","id":5792097,"avatar_url":"https://avatars.githubusercontent.com/u/5792097?v=3","gravatar_id":"","url":"https://api.github.com/users/andreaTP","html_url":"https://github.com/andreaTP","followers_url":"https://api.github.com/users/andreaTP/followers","following_url":"https://api.github.com/users/andreaTP/following{/other_user}","gists_url":"https://api.github.com/users/andreaTP/gists{/gist_id}","starred_url":"https://api.github.com/users/andreaTP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreaTP/subscriptions","organizations_url":"https://api.github.com/users/andreaTP/orgs","repos_url":"https://api.github.com/users/andreaTP/repos","events_url":"https://api.github.com/users/andreaTP/events{/privacy}","received_events_url":"https://api.github.com/users/andreaTP/received_events","type":"User","site_admin":false},"repo":{"id":34802802,"name":"scala-js","full_name":"andreaTP/scala-js","owner":{"login":"andreaTP","id":5792097,"avatar_url":"https://avatars.githubusercontent.com/u/5792097?v=3","gravatar_id":"","url":"https://api.github.com/users/andreaTP","html_url":"https://github.com/andreaTP","followers_url":"https://api.github.com/users/andreaTP/followers","following_url":"https://api.github.com/users/andreaTP/following{/other_user}","gists_url":"https://api.github.com/users/andreaTP/gists{/gist_id}","starred_url":"https://api.github.com/users/andreaTP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreaTP/subscriptions","organizations_url":"https://api.github.com/users/andreaTP/orgs","repos_url":"https://api.github.com/users/andreaTP/repos","events_url":"https://api.github.com/users/andreaTP/events{/privacy}","received_events_url":"https://api.github.com/users/andreaTP/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andreaTP/scala-js","description":"Scala.js, the Scala to JavaScript compiler","fork":true,"url":"https://api.github.com/repos/andreaTP/scala-js","forks_url":"https://api.github.com/repos/andreaTP/scala-js/forks","keys_url":"https://api.github.com/repos/andreaTP/scala-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andreaTP/scala-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andreaTP/scala-js/teams","hooks_url":"https://api.github.com/repos/andreaTP/scala-js/hooks","issue_events_url":"https://api.github.com/repos/andreaTP/scala-js/issues/events{/number}","events_url":"https://api.github.com/repos/andreaTP/scala-js/events","assignees_url":"https://api.github.com/repos/andreaTP/scala-js/assignees{/user}","branches_url":"https://api.github.com/repos/andreaTP/scala-js/branches{/branch}","tags_url":"https://api.github.com/repos/andreaTP/scala-js/tags","blobs_url":"https://api.github.com/repos/andreaTP/scala-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andreaTP/scala-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andreaTP/scala-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/andreaTP/scala-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andreaTP/scala-js/statuses/{sha}","languages_url":"https://api.github.com/repos/andreaTP/scala-js/languages","stargazers_url":"https://api.github.com/repos/andreaTP/scala-js/stargazers","contributors_url":"https://api.github.com/repos/andreaTP/scala-js/contributors","subscribers_url":"https://api.github.com/repos/andreaTP/scala-js/subscribers","subscription_url":"https://api.github.com/repos/andreaTP/scala-js/subscription","commits_url":"https://api.github.com/repos/andreaTP/scala-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/andreaTP/scala-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/andreaTP/scala-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/andreaTP/scala-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/andreaTP/scala-js/contents/{+path}","compare_url":"https://api.github.com/repos/andreaTP/scala-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andreaTP/scala-js/merges","archive_url":"https://api.github.com/repos/andreaTP/scala-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andreaTP/scala-js/downloads","issues_url":"https://api.github.com/repos/andreaTP/scala-js/issues{/number}","pulls_url":"https://api.github.com/repos/andreaTP/scala-js/pulls{/number}","milestones_url":"https://api.github.com/repos/andreaTP/scala-js/milestones{/number}","notifications_url":"https://api.github.com/repos/andreaTP/scala-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andreaTP/scala-js/labels{/name}","releases_url":"https://api.github.com/repos/andreaTP/scala-js/releases{/id}","created_at":"2015-04-29T15:44:28Z","updated_at":"2015-05-08T05:56:23Z","pushed_at":"2015-06-15T18:15:50Z","git_url":"git://github.com/andreaTP/scala-js.git","ssh_url":"git@github.com:andreaTP/scala-js.git","clone_url":"https://github.com/andreaTP/scala-js.git","svn_url":"https://github.com/andreaTP/scala-js","homepage":"http://www.scala-js.org/","size":8865,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"scala-js:master","ref":"master","sha":"6077016c29ee8a5330c0e7abf7b4d4be34f62627","user":{"login":"scala-js","id":6039724,"avatar_url":"https://avatars.githubusercontent.com/u/6039724?v=3","gravatar_id":"","url":"https://api.github.com/users/scala-js","html_url":"https://github.com/scala-js","followers_url":"https://api.github.com/users/scala-js/followers","following_url":"https://api.github.com/users/scala-js/following{/other_user}","gists_url":"https://api.github.com/users/scala-js/gists{/gist_id}","starred_url":"https://api.github.com/users/scala-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scala-js/subscriptions","organizations_url":"https://api.github.com/users/scala-js/orgs","repos_url":"https://api.github.com/users/scala-js/repos","events_url":"https://api.github.com/users/scala-js/events{/privacy}","received_events_url":"https://api.github.com/users/scala-js/received_events","type":"Organization","site_admin":false},"repo":{"id":8272315,"name":"scala-js","full_name":"scala-js/scala-js","owner":{"login":"scala-js","id":6039724,"avatar_url":"https://avatars.githubusercontent.com/u/6039724?v=3","gravatar_id":"","url":"https://api.github.com/users/scala-js","html_url":"https://github.com/scala-js","followers_url":"https://api.github.com/users/scala-js/followers","following_url":"https://api.github.com/users/scala-js/following{/other_user}","gists_url":"https://api.github.com/users/scala-js/gists{/gist_id}","starred_url":"https://api.github.com/users/scala-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scala-js/subscriptions","organizations_url":"https://api.github.com/users/scala-js/orgs","repos_url":"https://api.github.com/users/scala-js/repos","events_url":"https://api.github.com/users/scala-js/events{/privacy}","received_events_url":"https://api.github.com/users/scala-js/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scala-js/scala-js","description":"Scala.js, the Scala to JavaScript compiler","fork":false,"url":"https://api.github.com/repos/scala-js/scala-js","forks_url":"https://api.github.com/repos/scala-js/scala-js/forks","keys_url":"https://api.github.com/repos/scala-js/scala-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scala-js/scala-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scala-js/scala-js/teams","hooks_url":"https://api.github.com/repos/scala-js/scala-js/hooks","issue_events_url":"https://api.github.com/repos/scala-js/scala-js/issues/events{/number}","events_url":"https://api.github.com/repos/scala-js/scala-js/events","assignees_url":"https://api.github.com/repos/scala-js/scala-js/assignees{/user}","branches_url":"https://api.github.com/repos/scala-js/scala-js/branches{/branch}","tags_url":"https://api.github.com/repos/scala-js/scala-js/tags","blobs_url":"https://api.github.com/repos/scala-js/scala-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scala-js/scala-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scala-js/scala-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/scala-js/scala-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scala-js/scala-js/statuses/{sha}","languages_url":"https://api.github.com/repos/scala-js/scala-js/languages","stargazers_url":"https://api.github.com/repos/scala-js/scala-js/stargazers","contributors_url":"https://api.github.com/repos/scala-js/scala-js/contributors","subscribers_url":"https://api.github.com/repos/scala-js/scala-js/subscribers","subscription_url":"https://api.github.com/repos/scala-js/scala-js/subscription","commits_url":"https://api.github.com/repos/scala-js/scala-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/scala-js/scala-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/scala-js/scala-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/scala-js/scala-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/scala-js/scala-js/contents/{+path}","compare_url":"https://api.github.com/repos/scala-js/scala-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scala-js/scala-js/merges","archive_url":"https://api.github.com/repos/scala-js/scala-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scala-js/scala-js/downloads","issues_url":"https://api.github.com/repos/scala-js/scala-js/issues{/number}","pulls_url":"https://api.github.com/repos/scala-js/scala-js/pulls{/number}","milestones_url":"https://api.github.com/repos/scala-js/scala-js/milestones{/number}","notifications_url":"https://api.github.com/repos/scala-js/scala-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scala-js/scala-js/labels{/name}","releases_url":"https://api.github.com/repos/scala-js/scala-js/releases{/id}","created_at":"2013-02-18T16:33:55Z","updated_at":"2015-06-17T08:35:33Z","pushed_at":"2015-06-17T17:39:58Z","git_url":"git://github.com/scala-js/scala-js.git","ssh_url":"git@github.com:scala-js/scala-js.git","clone_url":"https://github.com/scala-js/scala-js.git","svn_url":"https://github.com/scala-js/scala-js","homepage":"http://www.scala-js.org/","size":16385,"stargazers_count":1720,"watchers_count":1720,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":147,"mirror_url":null,"open_issues_count":62,"forks":147,"open_issues":62,"watchers":1720,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/1710"},"html":{"href":"https://github.com/scala-js/scala-js/pull/1710"},"issue":{"href":"https://api.github.com/repos/scala-js/scala-js/issues/1710"},"comments":{"href":"https://api.github.com/repos/scala-js/scala-js/issues/1710/comments"},"review_comments":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/1710/comments"},"review_comment":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/1710/commits"},"statuses":{"href":"https://api.github.com/repos/scala-js/scala-js/statuses/29d91c9f7b0a0a1e20a1e2c6be36165d35fad9a9"}}}}