본문 바로가기

LinkedList

(5)
LinkedList를 활용한 도서 관리 프로그램 #include #include #include typedef struct Node { struct Book *data; struct Node *next; } node; typedef struct Book { // 제목, 저자, 출판사, 출판일, 가격 char title[30]; char author[20]; char publisher[20]; int date; int price; }; typedef struct LinkedList { int length; struct Node *fNode; }linkedList; // 1. 기본적인 링크드 리스트 함수 void initList(struct LinkedList*); node* getNodeAt(struct LinkedList*, int); void add..
C로 LinkedList 구현 +_+// (아 힘들었어;; ㅋㅋ) #include #include typedef struct Node { int data; struct Node *next; } node; typedef struct LinkedList { int length; struct Node *fNode; }linkedList; node* firstNode; int length; void initList(struct LinkedList*); node* getNodeAt(struct LinkedList*, int); void add(struct LinkedList*, int); void addInIndex(struct LinkedList*, int , int); void erase(struct LinkedList*, int); void replace(struct Li..
C#으로 LinkedList 구현 ^^ C#으로 구현한 LinkedList 여전히 null 값에 대한 의문이 남는다. Nullable을 구현해 줘야 되는거 같기는 한데, 제너릭에 자바에서 처럼 extends 라는 키워드 대신에 where 라는 키워드를 사용한다고 하는데 아직까지는 잘 모르겠다. 때문에 null 값으로 지정하지 않고 구현해봐따. ㅋ using System; using System.Collections.Generic; using System.Text; namespace List { public class LinkedList : ListInterface { private Node firstNode; private int length; public LinkedList() { reset(); } public void add(T entr..
Data Structure - ② Linked List 요번에는 소스코드를 한번.. 분석을 해보겠습니다.. -_-;; 제꺼라서 잘 설명할 자신이 있어요.. -_-;; 아래 포스팅한 글에서 보셨듯이 기본적으로 가지고 있어야할 멤버 변수들로는 리스트의 길이와.. 첫 노드가 무엇인지에 대한 정보를 담고 있는 firstNode 라는 객체가 있습니다. 그럼 노드가 무엇이고 어디다 쓰느냐?? 요것이 리스트의 Inner Class (내부 클래스) 로 삽입이 되어있는 Node 클래스 입니다. 물론 이 클래스를 따로 빼두어도 됩니다만.. 저는 내부 클래스로 사용을 했습니다. 접근 제어자는 모두 private.. 이게 왜 링크 기반의 리스트인지를 절실히 알려주는 부분이 바로 저!!! 부분입니다!! 4번째줄의 private Node next; 이부분이죠.. 노드라는 객체는 항상..
Data Structure - Linked Data 이전에 배열을 활용한 리스트를 만들어 봤는데.. 리스트를 만들 수 있는 방법이 또 하나 있다고 하더군요.. 일단 배열을 활용한 리스트 (ArrayList, 어레이리스트) 같은 경우에는 그 리스트의 길이가 한정이 되어 있습니다. 그리고 수정이나 삭제가 일어 날때, 뒤쪽에 있는 값들이 이동해 와야 한다는 단점이 있었습니다. 일단 값이 막 앞뒤로 이동한다는것들은 제외하고.. 리스트의 길이가 한정되어 있는걸 생각해보면.. 바로 배열 때문입니다.. 배열은 처음에 초기값을 설정을 해주기 때문에.. 그게 문제인거죠.. 그럼 이걸 근본적으로 해결할 수 있는 방법은 뭘까요?? 바로 이겁니다 -ㅅ-... 네.. 바로 염주죠..? 염주를 생각해봅시다.. 저 동글동글한 녀석들이 자료라고 생각을 한다면.. 이렇게 줄줄이 이어져..