{"id":21358438,"url":"https://github.com/danzigerrr/aisd-project-3-list-based-fifo-queue","last_synced_at":"2025-03-16T06:17:04.352Z","repository":{"id":130646050,"uuid":"352608121","full_name":"Danzigerrr/AiSD-Project-3-List-based-FIFO-queue","owner":"Danzigerrr","description":"repositry for the thirfd project algortymy i struktury danych","archived":false,"fork":false,"pushed_at":"2021-04-23T07:16:10.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-22T18:35:35.554Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Danzigerrr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-03-29T10:47:14.000Z","updated_at":"2021-08-11T09:04:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"d1f770db-4f61-41b4-87b9-6a8456a1b19e","html_url":"https://github.com/Danzigerrr/AiSD-Project-3-List-based-FIFO-queue","commit_stats":null,"previous_names":["danzigerrr/aisd-project-3-list-based-fifo-queue"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danzigerrr%2FAiSD-Project-3-List-based-FIFO-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danzigerrr%2FAiSD-Project-3-List-based-FIFO-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danzigerrr%2FAiSD-Project-3-List-based-FIFO-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danzigerrr%2FAiSD-Project-3-List-based-FIFO-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Danzigerrr","download_url":"https://codeload.github.com/Danzigerrr/AiSD-Project-3-List-based-FIFO-queue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243830955,"owners_count":20354856,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T05:16:52.529Z","updated_at":"2025-03-16T06:17:04.333Z","avatar_url":"https://github.com/Danzigerrr.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"This is my third proejkt for the subject called 'ALgortyhms and Data Structures' on the Gdańsk Univeristy of Technology\nI hope you like it ;) \n\n**List-based FIFO queue (AiSD 2021)**\n\nZadanie polega na implementacji kolejki FIFO opartej o listę jedno albo dwukierunkową. Jest to ono rozwinięciem zadania XOR linked list. i można w nim zastosować zaimplementowaną tam listę, można również wykorzystać szablon listy dostępny z biblioteki STL \u003clist\u003e.\nPoza funkcjonalnościami (ADD_BEG, ADD_END, DEL_BEG, DEL_END, PRINT_FORWARD, PRINT_BACKWARD) z zadania XOR linked list, lista udostępnia dodatkowo:\n\nSIZE - liczba elementów listy.\n\nKolejka jest strukturą danych wykorzystującą listę i udostępniającą następujące funkcjonalności powiązane z następującymi komendami:\nPUSH N - wepchnij element N na koniec kolejki.\nPOP - wyciągnij pierwszy element z kolejki.\nPRINT_QUEUE - drukuj kolejkę od pierwszego elementu do ostatnio wepchniętego.\nCOUNT - liczba elementów kolejki ≤ SIZE.\nGARBAGE_SOFT - wpisz wartość 0 do wszystkich elementów listy które nie należą do kolejki.\nGARBAGE_HARD - usuń wszystkie elementy listy które nie należą do kolejki.\nKolejka FIIO rozbudowuje listę XOR linked list o wskaźniki na początek (FRONT) i koniec kolejki (BACK). Po wepchnięciu elementu do kolejki wskaźnik na koniec kolejki (BACK) należy przesunąć na kolejny element listy. Po wyjęciu z kolejki wskaźnik na początek (FRONT) również należy przesunąć na kolejny element listy. Widać, że podczas wpychania i wyjmowania z listy kolejka będzie \"podążać wzdłuż listy\". Aby uniknąć wyczerpania pamięci i móc wykorzystać elementy listy przez kolejkę więcej niż raz, należy albo pracować na liście cyklicznej albo po dotarciu na koniec listy rozpocząć przeglądanie od początku. Należy również obsłużyć sytuacje wyjątkowe czyli: wepchnięcie elementu w wypadku pustej listy (brak elementów) albo pełnej listy (liczba elementów kolejki równa liczbie elementów listy) oraz wyciągnięcie elementu z pustej kolejki.\nKiedy lista jest pusta (nie posiada elementów) wskaźniki oczywiście wskazują na nullptr. Kiedy wpychamy element (PUSH N) do kolejki a lista jest pusta należy przed tą operacją dodać jeden element do listy. Tak samo należy powiększyć listę, kiedy znajdują się w niej już jakieś elementy ale wszystkie są zajęte przez kolejkę. Dodawany element listy powinien być przed elementem na który wskazuje wskaźnik na koniec kolejki (BACK).\n\nCo jakiś czas może okazać się przydatne usunięcie elementów listy, które w danym momencie nie przechowują żadnych elementów kolejki. Taka sytuacja może mieć miejsce kiedy przez dłuższy czas jedynie wpychaliśmy elementy do kolejki a później większość z nich wyciągnęliśmy. Obrazuje to często spotykaną sytuację związaną z przeciążeniem systemów obsługujących kolejkowane zadania np. system STOS. Normalnie kolejka w STOS'ie z zadaniami studentów jest pusta albo zawiera kilka zadań ale pod koniec deadline'ów potrafi się bardzo mocno rozrosnąć co prowadzi do przeciążenia a w rezultacie może owocować upadkiem systemu. Komenda GARBAGE_HARD realizuje właśnie funkcjonalność zmniejszania rozmiaru listy.\n\n------------------------------------------------------------------------------------------------------------------------ The task is to implement FIFO queue using doubly or singly linked list. It is an extension of XOR linked list assignment XOR linked list and the list implemented for that assignment can be reused; but also an STL \u003clist\u003e list can be used.\nIn addition to the functions of the XOR list (ADD_BEG, ADD_END, DEL_BEG, DEL_END, PRINT_FORWARD, PRINT_BACKWARD) from the XOR list assignment XOR linked list the list implements:\n\nSIZE - liczba elementów listy.\nThe queue is a data structure that uses list and provides functions corresponding to the following commands:\n\nPUSH N - add element N to the end of the queue.\nPOP - remove the first element from the queue.\nPRINT_QUEUE - print the queue from the first element to the lastly added.\nCOUNT - the number of elements in queue ≤ SIZE.\nGARBAGE_SOFT - change the values of all elements of the list that do not belong to the queue to 0.\nGARBAGE_HARD - remove all elements from the list that does not belong to the queue.\nThe FIFO queue extends the list to the pointers to the beginning (FRONT) and the end (BACK) of the queue. After inserting an element to the queue the pointer to the end of the queue (BACK) has to be changed so it will point to the next element of the list. After removing an element from the queue (FRONT) pointer has to start pointing at the element after the previously pointer by (FRONT). Notice, that by both removing and adding the element the queue has to “follow the list”. To avoid memory loss and to be able to reuse one can use a cyclical list or after reaching the end of the queue start from the beginning. Also, one has to handle exceptions: inserting an element to an empty queue (no elements), adding elements to full list (the number of elements of the queue equal to the number of elements of the list), or trying to remove elements from an empty queue.\nWhen the list is empty (no elements in it) the pointers point to nullptr. When adding an element (PUSH N) to the queue and the list is empty, then before executing the operation one element has to be added to the list. Similarly, the list has to be extended when the list is not empty, but all the elements are occupied by the queue. Inserted element should be inserted before the element pointed by pointer to the end of the queue (BACK).\n\nFrom time to time it might be useful to remove the elements that do not contain elements from the queue. Such a situation may occur if there were many insertions and after the insertions there was a sequence of pops. The situation is quite common in queuing systems. Consider for example STOS system. Normally the queues are empty or contains a few tasks. But near the deadlines they may grow considerably, which can overload the system and crash it. The operation to shrink the size of the list is implemented by GARBAGE_HARD.\n\n\n------------------------------------------------------------------------------------------------------------------------\nWejście\nPewna liczba komend uruchamiających określone funkcjonalności na liście albo na kolejce.\nWyjście\nWyniki działania odpowiednich komend na kolejce albo bezpośrednio na liście charakteryzującej się pewnym stanem. Początkowo lista jak i kolejka jest pusta a późniejszy jej stan zależy od kolejno wywoływanych komend. Niektóre komendy nie generują żadnego wyjścia np. (ADD_BEG N, PUSH N) ale mają wpływ na stan listy i pośrednio na stan kolejki oraz na kolejne komendy które wyświetlają pewne informacje np. (POP, PRINT_QUEUE).\n------------------------------------------------------------------------------------------------------------------------\nInput\nSome number of commands for the list or for the queue.\nOutput\nThe results of the operations of commands on the queue or directly on the list characterized by some state. Initially the list and the queue are empty, later their state depends on the commands. Some commands do not generate any output, but influence the state of the list and indirectly the queue and for the consecutive commands which print some in formations.\n------------------------------------------------------------------------------------------------------------------------\nPrzykład/Example\nWejście1/Input1\n\nPUSH 1\nPRINT_FORWARD\nPRINT_QUEUE\nSIZE\nCOUNT\nPUSH 2\nPRINT_FORWARD\nPRINT_QUEUE\nSIZE\nCOUNT\nPUSH 3\nPRINT_FORWARD\nPRINT_QUEUE\nSIZE\nCOUNT\nPOP\nPRINT_FORWARD\nPRINT_QUEUE\nSIZE\nCOUNT\nPUSH 4\nPRINT_FORWARD\nPRINT_QUEUE\nSIZE\nCOUNT\nPOP\nPRINT_FORWARD\nPRINT_QUEUE\nSIZE\nCOUNT\nPOP\nPRINT_FORWARD\nPRINT_QUEUE\nSIZE\nCOUNT\nPOP\nPRINT_FORWARD\nPRINT_QUEUE\nSIZE\nCOUNT\nPOP\nPRINT_FORWARD\nPRINT_QUEUE\nSIZE\nCOUNT\n\nWyjście1/Output1\n\n1 \n1\n1\n1\n2 1 \n1 2 \n2\n2\n3 2 1 \n1 2 3 \n3\n3\n1\n3 2 1 \n2 3 \n3\n2\n3 2 4 \n2 3 4 \n3\n3\n2\n3 2 4 \n3 4 \n3\n2\n3\n3 2 4 \n4 \n3\n1\n4\n3 2 4 \nNULL\n3\n0\nNULL\n3 2 4 \nNULL\n3\n0\n\nWejście2/Input2\n\nADD_BEG 1\nADD_BEG 2\nADD_BEG 3\nADD_BEG 4\nADD_BEG 5\nPRINT_FORWARD\nPRINT_QUEUE\nPUSH 10\nPRINT_FORWARD\nPRINT_QUEUE\nPUSH 11\nPRINT_FORWARD\nPRINT_QUEUE\nPUSH 12\nPRINT_FORWARD\nPRINT_QUEUE\nPUSH 13\nPRINT_FORWARD\nPRINT_QUEUE\nPUSH 14\nPRINT_FORWARD\nPRINT_QUEUE\nPUSH 15\nPRINT_FORWARD\nPRINT_QUEUE\nPOP\nPOP\nPOP\nPRINT_FORWARD\nPRINT_QUEUE\nPOP\nPOP\nPOP\nPRINT_FORWARD\nPRINT_QUEUE\n\nWyjście2/Output2\n\n5 4 3 2 1 \nNULL\n5 4 3 2 10 \n10 \n5 4 3 11 10 \n10 11 \n5 4 12 11 10 \n10 11 12 \n5 13 12 11 10 \n10 11 12 13 \n14 13 12 11 10 \n10 11 12 13 14 \n15 14 13 12 11 10 \n10 11 12 13 14 15 \n10\n11\n12\n15 14 13 12 11 10 \n13 14 15 \n13\n14\n15\n15 14 13 12 11 10 \nNULL\n\nWejście3/Input3\n\nADD_END 42\nPRINT_FORWARD\nGARBAGE_SOFT\nPRINT_FORWARD\nPUSH 10\nPRINT_FORWARD\nGARBAGE_SOFT\nPRINT_FORWARD\nADD_END 6\nADD_END 5\nADD_END 4\nADD_END 3\nADD_END 2\nADD_END 1\nADD_BEG 8\nADD_BEG 9\nPRINT_FORWARD\nPUSH 11\nPUSH 12\nPUSH 13\nPUSH 14\nPRINT_FORWARD\nGARBAGE_SOFT\nPRINT_FORWARD\n\nWyjście3/Output3\n\n42 \n0 \n10 \n10 \n9 8 10 6 5 4 3 2 1 \n12 11 10 6 5 4 3 14 13 \n12 11 10 0 0 0 0 14 13 \n\nWejście4/Input4\n\nPUSH 10\nPUSH 11\nPUSH 12\nPRINT_BACKWARD\nPRINT_QUEUE\nADD_BEG 1\nADD_END 6\nADD_BEG 2\nADD_BEG 3\nADD_END 5\nADD_END 4\nPRINT_BACKWARD\nPRINT_QUEUE\nPUSH 13\nPUSH 14\nPUSH 15\nPUSH 16\nPUSH 17\nPRINT_BACKWARD\nPRINT_QUEUE\nDEL_END\nPRINT_BACKWARD\nPRINT_QUEUE\nDEL_END\nPRINT_BACKWARD\nPRINT_QUEUE\nDEL_BEG\nPRINT_BACKWARD\nPRINT_QUEUE\nDEL_BEG\nPRINT_BACKWARD\nPRINT_QUEUE\n\nWyjście4/Output4\n\n10 11 12 \n10 11 12 \n4 5 6 10 11 12 1 2 3 \n10 11 12 \n16 17 6 10 11 12 13 14 15 \n10 11 12 13 14 15 16 17 \n17 6 10 11 12 13 14 15 \n10 11 12 13 14 15 17 \n6 10 11 12 13 14 15 \n10 11 12 13 14 15 \n6 10 11 12 13 14 \n10 11 12 13 14 \n6 10 11 12 13 \n10 11 12 13 \n\n\nWejście5/Input5\n\nADD_END 42\nPRINT_FORWARD\nGARBAGE_HARD\nPRINT_FORWARD\nPUSH 10\nPRINT_FORWARD\nGARBAGE_HARD\nPRINT_FORWARD\nADD_END 6\nADD_END 5\nADD_END 4\nADD_END 3\nADD_END 2\nADD_END 1\nADD_BEG 8\nADD_BEG 9\nPRINT_FORWARD\nPUSH 11\nPUSH 12\nPUSH 13\nPUSH 14\nPRINT_FORWARD\nGARBAGE_HARD\nPRINT_FORWARD\n\nWyjście5/Output5\n\n42 \nNULL \n10 \n10 \n9 8 10 6 5 4 3 2 1 \n12 11 10 6 5 4 3 14 13 \n12 11 10 14 13 \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanzigerrr%2Faisd-project-3-list-based-fifo-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanzigerrr%2Faisd-project-3-list-based-fifo-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanzigerrr%2Faisd-project-3-list-based-fifo-queue/lists"}