{"action":"created","comment":{"url":"https://api.github.com/repos/tgstation/-tg-station/pulls/comments/38181441","id":38181441,"diff_hunk":"@@ -0,0 +1,55 @@\n+\n+//Both count as failures, and they don't equate to each other\n+//this lets us do if(pop()) without having to specifically check for underflow\n+//same for if(push()) and overflow\n+#define STACK_OVERFLOW\t\"\"\n+#define STACK_UNDERFLOW\tnull\n+\n+\n+/datum/stack\n+\tvar/list/stack = list()\n+\tvar/max_elements = 0\n+\n+/datum/stack/New(list/elements,max)\n+\t..()\n+\tif(elements)\n+\t\tstack = elements.Copy()\n+\tif(max)\n+\t\tmax_elements = max\n+\n+/datum/stack/proc/pop()\n+\tif(is_empty())\n+\t\treturn STACK_UNDERFLOW\n+\t. = stack[stack.len]\n+\tstack.Cut(stack.len,0)","path":"code/__DATASTRUCTURES/stacks.dm","position":24,"original_position":24,"commit_id":"45ff37539e4c51ee50329b536a7e5d42b4c2ad69","original_commit_id":"45ff37539e4c51ee50329b536a7e5d42b4c2ad69","user":{"login":"RemieRichards","id":4043781,"avatar_url":"https://avatars.githubusercontent.com/u/4043781?v=3","gravatar_id":"","url":"https://api.github.com/users/RemieRichards","html_url":"https://github.com/RemieRichards","followers_url":"https://api.github.com/users/RemieRichards/followers","following_url":"https://api.github.com/users/RemieRichards/following{/other_user}","gists_url":"https://api.github.com/users/RemieRichards/gists{/gist_id}","starred_url":"https://api.github.com/users/RemieRichards/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RemieRichards/subscriptions","organizations_url":"https://api.github.com/users/RemieRichards/orgs","repos_url":"https://api.github.com/users/RemieRichards/repos","events_url":"https://api.github.com/users/RemieRichards/events{/privacy}","received_events_url":"https://api.github.com/users/RemieRichards/received_events","type":"User","site_admin":false},"body":"P.sure there have been troubles in the past of ```len--`` or equivalent syntax failing to actually destroy the element.\r\n```Cut()``` itself is faster than ```Remove()```, so it's decently fast already.","created_at":"2015-08-28T08:53:34Z","updated_at":"2015-08-28T08:53:34Z","html_url":"https://github.com/tgstation/-tg-station/pull/11396#discussion_r38181441","pull_request_url":"https://api.github.com/repos/tgstation/-tg-station/pulls/11396","_links":{"self":{"href":"https://api.github.com/repos/tgstation/-tg-station/pulls/comments/38181441"},"html":{"href":"https://github.com/tgstation/-tg-station/pull/11396#discussion_r38181441"},"pull_request":{"href":"https://api.github.com/repos/tgstation/-tg-station/pulls/11396"}}},"pull_request":{"url":"https://api.github.com/repos/tgstation/-tg-station/pulls/11396","id":43352448,"html_url":"https://github.com/tgstation/-tg-station/pull/11396","diff_url":"https://github.com/tgstation/-tg-station/pull/11396.diff","patch_url":"https://github.com/tgstation/-tg-station/pull/11396.patch","issue_url":"https://api.github.com/repos/tgstation/-tg-station/issues/11396","number":11396,"state":"open","locked":false,"title":"Datastructures: Stacks & Linked Lists","user":{"login":"RemieRichards","id":4043781,"avatar_url":"https://avatars.githubusercontent.com/u/4043781?v=3","gravatar_id":"","url":"https://api.github.com/users/RemieRichards","html_url":"https://github.com/RemieRichards","followers_url":"https://api.github.com/users/RemieRichards/followers","following_url":"https://api.github.com/users/RemieRichards/following{/other_user}","gists_url":"https://api.github.com/users/RemieRichards/gists{/gist_id}","starred_url":"https://api.github.com/users/RemieRichards/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RemieRichards/subscriptions","organizations_url":"https://api.github.com/users/RemieRichards/orgs","repos_url":"https://api.github.com/users/RemieRichards/repos","events_url":"https://api.github.com/users/RemieRichards/events{/privacy}","received_events_url":"https://api.github.com/users/RemieRichards/received_events","type":"User","site_admin":false},"body":"## General changes:\r\n* Adds the /__DATASTRUCTURES folder\r\n* Moves PriorityQueue data structure out of the AStar file, and into it's own file in /__DATASTRUCTURES\r\n* Adds Stacks, a data structure, to /__DATASTRUCTURES\r\n* Adds Linked Lists, a data structure, to /__DATASTRUCTURES\r\n\r\n## Stack:\r\nA stack is a First-in-Last-Out data structure, Elements are accessed with the ```pop()``` and ```push()``` methods primarily, ```pop()``` returns the last element in the stack, and removes it from the stack (there is also ```peek()``` which returns the last element without removing it), ```push()``` adds the element on to the end of the stack, making it the element returned by the next ```pop()```\r\n\r\n## Linked List:\r\nThese Linked Lists come in two flavours:\r\n* Linked List: a double-linked linked list, which stores ```linked_element```s which contain a reference to the element before them (or null), the element after them (or null) and the value they hold.\r\n* Linked List with Sentinels:\r\nA Linked List with Sentinel nodes will always have a len of 2 or more, because it always has a front(or bottom) sentinel and back(or top) sentinel. the point of sentinels is that a lot of Linked List algorithms are optimised for finding elements in NON-EMPTY Linked Lists, to deal with this, the concept of Sentinel Nodes was created. the ```front_sentinel``` is always ```contents[1]``` (first element) and the ```back_sentinel``` is always ```contents[contents.len]```(last element)\r\nWhen using Sentinels, procs that rely on ```.len``` (such as ```is_empty()```) have arguments to deal with this.\r\n\r\nI was bored so I implemented Stacks and Linked Lists (double linked lists) in Byond, woo.\r\n","created_at":"2015-08-26T00:26:20Z","updated_at":"2015-08-28T08:53:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5fb46cd59e6a58725b8238a90e37f7dd8d32e98f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tgstation/-tg-station/pulls/11396/commits","review_comments_url":"https://api.github.com/repos/tgstation/-tg-station/pulls/11396/comments","review_comment_url":"https://api.github.com/repos/tgstation/-tg-station/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tgstation/-tg-station/issues/11396/comments","statuses_url":"https://api.github.com/repos/tgstation/-tg-station/statuses/45ff37539e4c51ee50329b536a7e5d42b4c2ad69","head":{"label":"RemieRichards:DataStructures-Stacks&LinkedLists","ref":"DataStructures-Stacks&LinkedLists","sha":"45ff37539e4c51ee50329b536a7e5d42b4c2ad69","user":{"login":"RemieRichards","id":4043781,"avatar_url":"https://avatars.githubusercontent.com/u/4043781?v=3","gravatar_id":"","url":"https://api.github.com/users/RemieRichards","html_url":"https://github.com/RemieRichards","followers_url":"https://api.github.com/users/RemieRichards/followers","following_url":"https://api.github.com/users/RemieRichards/following{/other_user}","gists_url":"https://api.github.com/users/RemieRichards/gists{/gist_id}","starred_url":"https://api.github.com/users/RemieRichards/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RemieRichards/subscriptions","organizations_url":"https://api.github.com/users/RemieRichards/orgs","repos_url":"https://api.github.com/users/RemieRichards/repos","events_url":"https://api.github.com/users/RemieRichards/events{/privacy}","received_events_url":"https://api.github.com/users/RemieRichards/received_events","type":"User","site_admin":false},"repo":{"id":12466296,"name":"-tg-station","full_name":"RemieRichards/-tg-station","owner":{"login":"RemieRichards","id":4043781,"avatar_url":"https://avatars.githubusercontent.com/u/4043781?v=3","gravatar_id":"","url":"https://api.github.com/users/RemieRichards","html_url":"https://github.com/RemieRichards","followers_url":"https://api.github.com/users/RemieRichards/followers","following_url":"https://api.github.com/users/RemieRichards/following{/other_user}","gists_url":"https://api.github.com/users/RemieRichards/gists{/gist_id}","starred_url":"https://api.github.com/users/RemieRichards/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RemieRichards/subscriptions","organizations_url":"https://api.github.com/users/RemieRichards/orgs","repos_url":"https://api.github.com/users/RemieRichards/repos","events_url":"https://api.github.com/users/RemieRichards/events{/privacy}","received_events_url":"https://api.github.com/users/RemieRichards/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RemieRichards/-tg-station","description":"/tg/'s SS13 branch","fork":true,"url":"https://api.github.com/repos/RemieRichards/-tg-station","forks_url":"https://api.github.com/repos/RemieRichards/-tg-station/forks","keys_url":"https://api.github.com/repos/RemieRichards/-tg-station/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RemieRichards/-tg-station/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RemieRichards/-tg-station/teams","hooks_url":"https://api.github.com/repos/RemieRichards/-tg-station/hooks","issue_events_url":"https://api.github.com/repos/RemieRichards/-tg-station/issues/events{/number}","events_url":"https://api.github.com/repos/RemieRichards/-tg-station/events","assignees_url":"https://api.github.com/repos/RemieRichards/-tg-station/assignees{/user}","branches_url":"https://api.github.com/repos/RemieRichards/-tg-station/branches{/branch}","tags_url":"https://api.github.com/repos/RemieRichards/-tg-station/tags","blobs_url":"https://api.github.com/repos/RemieRichards/-tg-station/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RemieRichards/-tg-station/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RemieRichards/-tg-station/git/refs{/sha}","trees_url":"https://api.github.com/repos/RemieRichards/-tg-station/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RemieRichards/-tg-station/statuses/{sha}","languages_url":"https://api.github.com/repos/RemieRichards/-tg-station/languages","stargazers_url":"https://api.github.com/repos/RemieRichards/-tg-station/stargazers","contributors_url":"https://api.github.com/repos/RemieRichards/-tg-station/contributors","subscribers_url":"https://api.github.com/repos/RemieRichards/-tg-station/subscribers","subscription_url":"https://api.github.com/repos/RemieRichards/-tg-station/subscription","commits_url":"https://api.github.com/repos/RemieRichards/-tg-station/commits{/sha}","git_commits_url":"https://api.github.com/repos/RemieRichards/-tg-station/git/commits{/sha}","comments_url":"https://api.github.com/repos/RemieRichards/-tg-station/comments{/number}","issue_comment_url":"https://api.github.com/repos/RemieRichards/-tg-station/issues/comments{/number}","contents_url":"https://api.github.com/repos/RemieRichards/-tg-station/contents/{+path}","compare_url":"https://api.github.com/repos/RemieRichards/-tg-station/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RemieRichards/-tg-station/merges","archive_url":"https://api.github.com/repos/RemieRichards/-tg-station/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RemieRichards/-tg-station/downloads","issues_url":"https://api.github.com/repos/RemieRichards/-tg-station/issues{/number}","pulls_url":"https://api.github.com/repos/RemieRichards/-tg-station/pulls{/number}","milestones_url":"https://api.github.com/repos/RemieRichards/-tg-station/milestones{/number}","notifications_url":"https://api.github.com/repos/RemieRichards/-tg-station/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RemieRichards/-tg-station/labels{/name}","releases_url":"https://api.github.com/repos/RemieRichards/-tg-station/releases{/id}","created_at":"2013-08-29T17:14:29Z","updated_at":"2014-06-19T15:13:34Z","pushed_at":"2015-08-26T00:18:16Z","git_url":"git://github.com/RemieRichards/-tg-station.git","ssh_url":"git@github.com:RemieRichards/-tg-station.git","clone_url":"https://github.com/RemieRichards/-tg-station.git","svn_url":"https://github.com/RemieRichards/-tg-station","homepage":"","size":535404,"stargazers_count":0,"watchers_count":0,"language":"DM","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"tgstation:master","ref":"master","sha":"67a7eb2d5f3c5a403c12a3d2151300b3872e3c1c","user":{"login":"tgstation","id":1363778,"avatar_url":"https://avatars.githubusercontent.com/u/1363778?v=3","gravatar_id":"","url":"https://api.github.com/users/tgstation","html_url":"https://github.com/tgstation","followers_url":"https://api.github.com/users/tgstation/followers","following_url":"https://api.github.com/users/tgstation/following{/other_user}","gists_url":"https://api.github.com/users/tgstation/gists{/gist_id}","starred_url":"https://api.github.com/users/tgstation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgstation/subscriptions","organizations_url":"https://api.github.com/users/tgstation/orgs","repos_url":"https://api.github.com/users/tgstation/repos","events_url":"https://api.github.com/users/tgstation/events{/privacy}","received_events_url":"https://api.github.com/users/tgstation/received_events","type":"Organization","site_admin":false},"repo":{"id":3234987,"name":"-tg-station","full_name":"tgstation/-tg-station","owner":{"login":"tgstation","id":1363778,"avatar_url":"https://avatars.githubusercontent.com/u/1363778?v=3","gravatar_id":"","url":"https://api.github.com/users/tgstation","html_url":"https://github.com/tgstation","followers_url":"https://api.github.com/users/tgstation/followers","following_url":"https://api.github.com/users/tgstation/following{/other_user}","gists_url":"https://api.github.com/users/tgstation/gists{/gist_id}","starred_url":"https://api.github.com/users/tgstation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgstation/subscriptions","organizations_url":"https://api.github.com/users/tgstation/orgs","repos_url":"https://api.github.com/users/tgstation/repos","events_url":"https://api.github.com/users/tgstation/events{/privacy}","received_events_url":"https://api.github.com/users/tgstation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tgstation/-tg-station","description":"the /tg/station branch of SS13","fork":false,"url":"https://api.github.com/repos/tgstation/-tg-station","forks_url":"https://api.github.com/repos/tgstation/-tg-station/forks","keys_url":"https://api.github.com/repos/tgstation/-tg-station/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tgstation/-tg-station/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tgstation/-tg-station/teams","hooks_url":"https://api.github.com/repos/tgstation/-tg-station/hooks","issue_events_url":"https://api.github.com/repos/tgstation/-tg-station/issues/events{/number}","events_url":"https://api.github.com/repos/tgstation/-tg-station/events","assignees_url":"https://api.github.com/repos/tgstation/-tg-station/assignees{/user}","branches_url":"https://api.github.com/repos/tgstation/-tg-station/branches{/branch}","tags_url":"https://api.github.com/repos/tgstation/-tg-station/tags","blobs_url":"https://api.github.com/repos/tgstation/-tg-station/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tgstation/-tg-station/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tgstation/-tg-station/git/refs{/sha}","trees_url":"https://api.github.com/repos/tgstation/-tg-station/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tgstation/-tg-station/statuses/{sha}","languages_url":"https://api.github.com/repos/tgstation/-tg-station/languages","stargazers_url":"https://api.github.com/repos/tgstation/-tg-station/stargazers","contributors_url":"https://api.github.com/repos/tgstation/-tg-station/contributors","subscribers_url":"https://api.github.com/repos/tgstation/-tg-station/subscribers","subscription_url":"https://api.github.com/repos/tgstation/-tg-station/subscription","commits_url":"https://api.github.com/repos/tgstation/-tg-station/commits{/sha}","git_commits_url":"https://api.github.com/repos/tgstation/-tg-station/git/commits{/sha}","comments_url":"https://api.github.com/repos/tgstation/-tg-station/comments{/number}","issue_comment_url":"https://api.github.com/repos/tgstation/-tg-station/issues/comments{/number}","contents_url":"https://api.github.com/repos/tgstation/-tg-station/contents/{+path}","compare_url":"https://api.github.com/repos/tgstation/-tg-station/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tgstation/-tg-station/merges","archive_url":"https://api.github.com/repos/tgstation/-tg-station/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tgstation/-tg-station/downloads","issues_url":"https://api.github.com/repos/tgstation/-tg-station/issues{/number}","pulls_url":"https://api.github.com/repos/tgstation/-tg-station/pulls{/number}","milestones_url":"https://api.github.com/repos/tgstation/-tg-station/milestones{/number}","notifications_url":"https://api.github.com/repos/tgstation/-tg-station/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tgstation/-tg-station/labels{/name}","releases_url":"https://api.github.com/repos/tgstation/-tg-station/releases{/id}","created_at":"2012-01-21T17:32:47Z","updated_at":"2015-08-23T21:18:50Z","pushed_at":"2015-08-28T07:53:19Z","git_url":"git://github.com/tgstation/-tg-station.git","ssh_url":"git@github.com:tgstation/-tg-station.git","clone_url":"https://github.com/tgstation/-tg-station.git","svn_url":"https://github.com/tgstation/-tg-station","homepage":"http://www.tgstation13.org/","size":742546,"stargazers_count":238,"watchers_count":238,"language":"DM","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":814,"mirror_url":null,"open_issues_count":867,"forks":814,"open_issues":867,"watchers":238,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tgstation/-tg-station/pulls/11396"},"html":{"href":"https://github.com/tgstation/-tg-station/pull/11396"},"issue":{"href":"https://api.github.com/repos/tgstation/-tg-station/issues/11396"},"comments":{"href":"https://api.github.com/repos/tgstation/-tg-station/issues/11396/comments"},"review_comments":{"href":"https://api.github.com/repos/tgstation/-tg-station/pulls/11396/comments"},"review_comment":{"href":"https://api.github.com/repos/tgstation/-tg-station/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tgstation/-tg-station/pulls/11396/commits"},"statuses":{"href":"https://api.github.com/repos/tgstation/-tg-station/statuses/45ff37539e4c51ee50329b536a7e5d42b4c2ad69"}}}}