{"action":"created","issue":{"url":"https://api.github.com/repos/google/closure-library/issues/930","repository_url":"https://api.github.com/repos/google/closure-library","labels_url":"https://api.github.com/repos/google/closure-library/issues/930/labels{/name}","comments_url":"https://api.github.com/repos/google/closure-library/issues/930/comments","events_url":"https://api.github.com/repos/google/closure-library/issues/930/events","html_url":"https://github.com/google/closure-library/pull/930","id":362265874,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE3MDMzNDcx","number":930,"title":"Efficiently copying AVL trees.","user":{"login":"kevin-dp","id":17384006,"node_id":"MDQ6VXNlcjE3Mzg0MDA2","avatar_url":"https://avatars1.githubusercontent.com/u/17384006?v=4","gravatar_id":"","url":"https://api.github.com/users/kevin-dp","html_url":"https://github.com/kevin-dp","followers_url":"https://api.github.com/users/kevin-dp/followers","following_url":"https://api.github.com/users/kevin-dp/following{/other_user}","gists_url":"https://api.github.com/users/kevin-dp/gists{/gist_id}","starred_url":"https://api.github.com/users/kevin-dp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevin-dp/subscriptions","organizations_url":"https://api.github.com/users/kevin-dp/orgs","repos_url":"https://api.github.com/users/kevin-dp/repos","events_url":"https://api.github.com/users/kevin-dp/events{/privacy}","received_events_url":"https://api.github.com/users/kevin-dp/received_events","type":"User","site_admin":false},"labels":[{"id":196840518,"node_id":"MDU6TGFiZWwxOTY4NDA1MTg=","url":"https://api.github.com/repos/google/closure-library/labels/CLA:%20yes","name":"CLA: yes","color":"009800","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-20T16:25:45Z","updated_at":"2018-10-08T23:46:02Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/google/closure-library/pulls/930","html_url":"https://github.com/google/closure-library/pull/930","diff_url":"https://github.com/google/closure-library/pull/930.diff","patch_url":"https://github.com/google/closure-library/pull/930.patch"},"body":"Currently the `AvlTree` does not provide a way to efficiently make a deep copy of the tree.\r\nHence, programmers need to fetch all values, manually deep copy the values, and then insert them in the new tree:\r\n\r\n```\r\nconst tree = new goog.structs.AvlTree();\r\n// ...\r\nconst copy = new goog.structs.AvlTree();\r\n\r\n// Inneficient deep copy: O(n * k * log(n)),\r\n// where k is the time complexity to copy a value\r\ntree.getValues()\r\n    .forEach(v => copy.add(JSON.parse(JSON.stringify(v))));\r\n```\r\n\r\nThe above approach is inneficient since it is in `O(n * k * log(n))`, where `k` is the time complexity to copy a value contained by the tree.\r\n\r\nThis pull request extends the `AvlTree` with a `copy` method which deep copies the tree in `O(n * k)`."},"comment":{"url":"https://api.github.com/repos/google/closure-library/issues/comments/428013872","html_url":"https://github.com/google/closure-library/pull/930#issuecomment-428013872","issue_url":"https://api.github.com/repos/google/closure-library/issues/930","id":428013872,"node_id":"MDEyOklzc3VlQ29tbWVudDQyODAxMzg3Mg==","user":{"login":"jplaisted","id":1565017,"node_id":"MDQ6VXNlcjE1NjUwMTc=","avatar_url":"https://avatars0.githubusercontent.com/u/1565017?v=4","gravatar_id":"","url":"https://api.github.com/users/jplaisted","html_url":"https://github.com/jplaisted","followers_url":"https://api.github.com/users/jplaisted/followers","following_url":"https://api.github.com/users/jplaisted/following{/other_user}","gists_url":"https://api.github.com/users/jplaisted/gists{/gist_id}","starred_url":"https://api.github.com/users/jplaisted/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jplaisted/subscriptions","organizations_url":"https://api.github.com/users/jplaisted/orgs","repos_url":"https://api.github.com/users/jplaisted/repos","events_url":"https://api.github.com/users/jplaisted/events{/privacy}","received_events_url":"https://api.github.com/users/jplaisted/received_events","type":"User","site_admin":false},"created_at":"2018-10-08T23:46:02Z","updated_at":"2018-10-08T23:46:02Z","author_association":"CONTRIBUTOR","body":"I'm going to merge this with a few edits. The only one that impacts functionality is that it won't use `JSON` by default at all. The default behavior (no copy function) will be assignment copy (e.g. the `=` operator, so it won't be a deep copy by default). You can copy with `JSON` if you like."}}
{"actor":{"display_login":"jplaisted"}}