{"action":"created","comment":{"url":"https://api.github.com/repos/brayniac/histogram/pulls/comments/64790448","id":64790448,"diff_hunk":"@@ -403,6 +403,60 @@ impl Histogram {\n         }\n     }\n \n+\n+    /// decrement the count for a value. This functionality is best\n+    /// used to remove previously inserted from the histogram.\n+    ///\n+    /// # Example\n+    /// ```\n+    /// # use histogram::{Histogram,HistogramConfig};\n+    /// let mut h = Histogram::new().unwrap();\n+    ///\n+    /// h.increment(1).unwrap();\n+    /// assert_eq!(h.get(1).unwrap(), 1);\n+    /// h.decrement(1).unwrap();\n+    /// assert_eq!(h.get(1).unwrap(), 0);\n+    pub fn decrement(&mut self, value: u64) -> Result<(), &'static str> {\n+        self.derecord(value, 1_u64)\n+    }\n+\n+    /// remove count for value from histogram. This functionality is\n+    /// best used to remove previously inserted from the histogram.\n+    ///\n+    /// # Example\n+    /// ```\n+    /// # use histogram::{Histogram,HistogramConfig};\n+    /// let mut h = Histogram::new().unwrap();\n+    ///\n+    /// h.record(1, 1).unwrap();\n+    /// h.record(2, 2).unwrap();\n+    /// h.derecord(1, 1).unwrap();\n+    ///\n+    /// assert_eq!(h.get(2).unwrap(), 2);\n+    /// assert_eq!(h.get(1).unwrap(), 0);\n+    pub fn derecord(&mut self, value: u64, count: u64) -> Result<(), &'static str> {\n+        self.data.counters.entries_total = self.data.counters.entries_total.saturating_sub(count);\n+        if value < 1 {\n+            self.data.counters.missed_small = self.data.counters.missed_small.saturating_sub(count);\n+            Err(\"sample value too small\")\n+        } else if value > self.config.max_value {\n+            self.data.counters.missed_large = self.data.counters.missed_large.saturating_sub(count);\n+            Err(\"sample value too large\")\n+        } else {\n+            match self.get_index(value) {\n+                Some(index) => {\n+                    self.data.data[index] = self.data.data[index].saturating_sub(count);\n+                    Ok(())\n+                }\n+                None => {\n+                    self.data.counters.missed_unknown =","path":"src/lib.rs","position":50,"original_position":50,"commit_id":"674f5e62a2b108ab547237592ecd47952d825301","original_commit_id":"674f5e62a2b108ab547237592ecd47952d825301","user":{"login":"wictory","id":1951419,"avatar_url":"https://avatars.githubusercontent.com/u/1951419?v=3","gravatar_id":"","url":"https://api.github.com/users/wictory","html_url":"https://github.com/wictory","followers_url":"https://api.github.com/users/wictory/followers","following_url":"https://api.github.com/users/wictory/following{/other_user}","gists_url":"https://api.github.com/users/wictory/gists{/gist_id}","starred_url":"https://api.github.com/users/wictory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wictory/subscriptions","organizations_url":"https://api.github.com/users/wictory/orgs","repos_url":"https://api.github.com/users/wictory/repos","events_url":"https://api.github.com/users/wictory/events{/privacy}","received_events_url":"https://api.github.com/users/wictory/received_events","type":"User","site_admin":false},"body":"when I'm coming to think of it, maybe missed_unkown should be increased on decrease also?","created_at":"2016-05-26T17:54:31Z","updated_at":"2016-05-26T17:54:31Z","html_url":"https://github.com/brayniac/histogram/pull/14#discussion_r64790448","pull_request_url":"https://api.github.com/repos/brayniac/histogram/pulls/14","_links":{"self":{"href":"https://api.github.com/repos/brayniac/histogram/pulls/comments/64790448"},"html":{"href":"https://github.com/brayniac/histogram/pull/14#discussion_r64790448"},"pull_request":{"href":"https://api.github.com/repos/brayniac/histogram/pulls/14"}}},"pull_request":{"url":"https://api.github.com/repos/brayniac/histogram/pulls/14","id":71562345,"html_url":"https://github.com/brayniac/histogram/pull/14","diff_url":"https://github.com/brayniac/histogram/pull/14.diff","patch_url":"https://github.com/brayniac/histogram/pull/14.patch","issue_url":"https://api.github.com/repos/brayniac/histogram/issues/14","number":14,"state":"open","locked":false,"title":"Added decrement functionality, with tests.","user":{"login":"wictory","id":1951419,"avatar_url":"https://avatars.githubusercontent.com/u/1951419?v=3","gravatar_id":"","url":"https://api.github.com/users/wictory","html_url":"https://github.com/wictory","followers_url":"https://api.github.com/users/wictory/followers","following_url":"https://api.github.com/users/wictory/following{/other_user}","gists_url":"https://api.github.com/users/wictory/gists{/gist_id}","starred_url":"https://api.github.com/users/wictory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wictory/subscriptions","organizations_url":"https://api.github.com/users/wictory/orgs","repos_url":"https://api.github.com/users/wictory/repos","events_url":"https://api.github.com/users/wictory/events{/privacy}","received_events_url":"https://api.github.com/users/wictory/received_events","type":"User","site_admin":false},"body":"I added ```fn decrement()```, and ```fn derecord()``` function to undo increments and records to the histogram. I also added som tests to show that the functions works as intended. Unfortunately, the tests needs to pull in rand for more senseful tests.\r\n\r\nI need this functionality to keep track of window distributions of time series.\r\n","created_at":"2016-05-26T14:12:00Z","updated_at":"2016-05-26T17:54:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2db29f8459dba6aceb16f94345c58dfe93a94c71","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/brayniac/histogram/pulls/14/commits","review_comments_url":"https://api.github.com/repos/brayniac/histogram/pulls/14/comments","review_comment_url":"https://api.github.com/repos/brayniac/histogram/pulls/comments{/number}","comments_url":"https://api.github.com/repos/brayniac/histogram/issues/14/comments","statuses_url":"https://api.github.com/repos/brayniac/histogram/statuses/674f5e62a2b108ab547237592ecd47952d825301","head":{"label":"wictory:add_decrement","ref":"add_decrement","sha":"674f5e62a2b108ab547237592ecd47952d825301","user":{"login":"wictory","id":1951419,"avatar_url":"https://avatars.githubusercontent.com/u/1951419?v=3","gravatar_id":"","url":"https://api.github.com/users/wictory","html_url":"https://github.com/wictory","followers_url":"https://api.github.com/users/wictory/followers","following_url":"https://api.github.com/users/wictory/following{/other_user}","gists_url":"https://api.github.com/users/wictory/gists{/gist_id}","starred_url":"https://api.github.com/users/wictory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wictory/subscriptions","organizations_url":"https://api.github.com/users/wictory/orgs","repos_url":"https://api.github.com/users/wictory/repos","events_url":"https://api.github.com/users/wictory/events{/privacy}","received_events_url":"https://api.github.com/users/wictory/received_events","type":"User","site_admin":false},"repo":{"id":59755196,"name":"histogram","full_name":"wictory/histogram","owner":{"login":"wictory","id":1951419,"avatar_url":"https://avatars.githubusercontent.com/u/1951419?v=3","gravatar_id":"","url":"https://api.github.com/users/wictory","html_url":"https://github.com/wictory","followers_url":"https://api.github.com/users/wictory/followers","following_url":"https://api.github.com/users/wictory/following{/other_user}","gists_url":"https://api.github.com/users/wictory/gists{/gist_id}","starred_url":"https://api.github.com/users/wictory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wictory/subscriptions","organizations_url":"https://api.github.com/users/wictory/orgs","repos_url":"https://api.github.com/users/wictory/repos","events_url":"https://api.github.com/users/wictory/events{/privacy}","received_events_url":"https://api.github.com/users/wictory/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wictory/histogram","description":"rust histogram and percentile stats","fork":true,"url":"https://api.github.com/repos/wictory/histogram","forks_url":"https://api.github.com/repos/wictory/histogram/forks","keys_url":"https://api.github.com/repos/wictory/histogram/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wictory/histogram/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wictory/histogram/teams","hooks_url":"https://api.github.com/repos/wictory/histogram/hooks","issue_events_url":"https://api.github.com/repos/wictory/histogram/issues/events{/number}","events_url":"https://api.github.com/repos/wictory/histogram/events","assignees_url":"https://api.github.com/repos/wictory/histogram/assignees{/user}","branches_url":"https://api.github.com/repos/wictory/histogram/branches{/branch}","tags_url":"https://api.github.com/repos/wictory/histogram/tags","blobs_url":"https://api.github.com/repos/wictory/histogram/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wictory/histogram/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wictory/histogram/git/refs{/sha}","trees_url":"https://api.github.com/repos/wictory/histogram/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wictory/histogram/statuses/{sha}","languages_url":"https://api.github.com/repos/wictory/histogram/languages","stargazers_url":"https://api.github.com/repos/wictory/histogram/stargazers","contributors_url":"https://api.github.com/repos/wictory/histogram/contributors","subscribers_url":"https://api.github.com/repos/wictory/histogram/subscribers","subscription_url":"https://api.github.com/repos/wictory/histogram/subscription","commits_url":"https://api.github.com/repos/wictory/histogram/commits{/sha}","git_commits_url":"https://api.github.com/repos/wictory/histogram/git/commits{/sha}","comments_url":"https://api.github.com/repos/wictory/histogram/comments{/number}","issue_comment_url":"https://api.github.com/repos/wictory/histogram/issues/comments{/number}","contents_url":"https://api.github.com/repos/wictory/histogram/contents/{+path}","compare_url":"https://api.github.com/repos/wictory/histogram/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wictory/histogram/merges","archive_url":"https://api.github.com/repos/wictory/histogram/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wictory/histogram/downloads","issues_url":"https://api.github.com/repos/wictory/histogram/issues{/number}","pulls_url":"https://api.github.com/repos/wictory/histogram/pulls{/number}","milestones_url":"https://api.github.com/repos/wictory/histogram/milestones{/number}","notifications_url":"https://api.github.com/repos/wictory/histogram/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wictory/histogram/labels{/name}","releases_url":"https://api.github.com/repos/wictory/histogram/releases{/id}","deployments_url":"https://api.github.com/repos/wictory/histogram/deployments","created_at":"2016-05-26T14:05:27Z","updated_at":"2016-05-26T14:05:28Z","pushed_at":"2016-05-26T16:55:06Z","git_url":"git://github.com/wictory/histogram.git","ssh_url":"git@github.com:wictory/histogram.git","clone_url":"https://github.com/wictory/histogram.git","svn_url":"https://github.com/wictory/histogram","homepage":"","size":908,"stargazers_count":0,"watchers_count":0,"language":"Rust","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":"brayniac:master","ref":"master","sha":"80a760db3d4f6807e44115e4f9e097fd1fa9dc8f","user":{"login":"brayniac","id":10478487,"avatar_url":"https://avatars.githubusercontent.com/u/10478487?v=3","gravatar_id":"","url":"https://api.github.com/users/brayniac","html_url":"https://github.com/brayniac","followers_url":"https://api.github.com/users/brayniac/followers","following_url":"https://api.github.com/users/brayniac/following{/other_user}","gists_url":"https://api.github.com/users/brayniac/gists{/gist_id}","starred_url":"https://api.github.com/users/brayniac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brayniac/subscriptions","organizations_url":"https://api.github.com/users/brayniac/orgs","repos_url":"https://api.github.com/users/brayniac/repos","events_url":"https://api.github.com/users/brayniac/events{/privacy}","received_events_url":"https://api.github.com/users/brayniac/received_events","type":"User","site_admin":false},"repo":{"id":38215591,"name":"histogram","full_name":"brayniac/histogram","owner":{"login":"brayniac","id":10478487,"avatar_url":"https://avatars.githubusercontent.com/u/10478487?v=3","gravatar_id":"","url":"https://api.github.com/users/brayniac","html_url":"https://github.com/brayniac","followers_url":"https://api.github.com/users/brayniac/followers","following_url":"https://api.github.com/users/brayniac/following{/other_user}","gists_url":"https://api.github.com/users/brayniac/gists{/gist_id}","starred_url":"https://api.github.com/users/brayniac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brayniac/subscriptions","organizations_url":"https://api.github.com/users/brayniac/orgs","repos_url":"https://api.github.com/users/brayniac/repos","events_url":"https://api.github.com/users/brayniac/events{/privacy}","received_events_url":"https://api.github.com/users/brayniac/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/brayniac/histogram","description":"rust histogram and percentile stats","fork":false,"url":"https://api.github.com/repos/brayniac/histogram","forks_url":"https://api.github.com/repos/brayniac/histogram/forks","keys_url":"https://api.github.com/repos/brayniac/histogram/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brayniac/histogram/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brayniac/histogram/teams","hooks_url":"https://api.github.com/repos/brayniac/histogram/hooks","issue_events_url":"https://api.github.com/repos/brayniac/histogram/issues/events{/number}","events_url":"https://api.github.com/repos/brayniac/histogram/events","assignees_url":"https://api.github.com/repos/brayniac/histogram/assignees{/user}","branches_url":"https://api.github.com/repos/brayniac/histogram/branches{/branch}","tags_url":"https://api.github.com/repos/brayniac/histogram/tags","blobs_url":"https://api.github.com/repos/brayniac/histogram/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brayniac/histogram/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brayniac/histogram/git/refs{/sha}","trees_url":"https://api.github.com/repos/brayniac/histogram/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brayniac/histogram/statuses/{sha}","languages_url":"https://api.github.com/repos/brayniac/histogram/languages","stargazers_url":"https://api.github.com/repos/brayniac/histogram/stargazers","contributors_url":"https://api.github.com/repos/brayniac/histogram/contributors","subscribers_url":"https://api.github.com/repos/brayniac/histogram/subscribers","subscription_url":"https://api.github.com/repos/brayniac/histogram/subscription","commits_url":"https://api.github.com/repos/brayniac/histogram/commits{/sha}","git_commits_url":"https://api.github.com/repos/brayniac/histogram/git/commits{/sha}","comments_url":"https://api.github.com/repos/brayniac/histogram/comments{/number}","issue_comment_url":"https://api.github.com/repos/brayniac/histogram/issues/comments{/number}","contents_url":"https://api.github.com/repos/brayniac/histogram/contents/{+path}","compare_url":"https://api.github.com/repos/brayniac/histogram/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brayniac/histogram/merges","archive_url":"https://api.github.com/repos/brayniac/histogram/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brayniac/histogram/downloads","issues_url":"https://api.github.com/repos/brayniac/histogram/issues{/number}","pulls_url":"https://api.github.com/repos/brayniac/histogram/pulls{/number}","milestones_url":"https://api.github.com/repos/brayniac/histogram/milestones{/number}","notifications_url":"https://api.github.com/repos/brayniac/histogram/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brayniac/histogram/labels{/name}","releases_url":"https://api.github.com/repos/brayniac/histogram/releases{/id}","deployments_url":"https://api.github.com/repos/brayniac/histogram/deployments","created_at":"2015-06-28T21:52:20Z","updated_at":"2016-03-26T00:11:40Z","pushed_at":"2016-05-26T16:55:06Z","git_url":"git://github.com/brayniac/histogram.git","ssh_url":"git@github.com:brayniac/histogram.git","clone_url":"https://github.com/brayniac/histogram.git","svn_url":"https://github.com/brayniac/histogram","homepage":"","size":905,"stargazers_count":6,"watchers_count":6,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/brayniac/histogram/pulls/14"},"html":{"href":"https://github.com/brayniac/histogram/pull/14"},"issue":{"href":"https://api.github.com/repos/brayniac/histogram/issues/14"},"comments":{"href":"https://api.github.com/repos/brayniac/histogram/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/brayniac/histogram/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/brayniac/histogram/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/brayniac/histogram/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/brayniac/histogram/statuses/674f5e62a2b108ab547237592ecd47952d825301"}}}}
{"actor":{"display_login":"wictory"}}