1. 선언
Dim ArrList 이름 As New ArrayList()
2. 속성
Count - 어레이리스트에 실제로 포함된 요소의 수를 불러온다. 배열 요소의 갯수 >> Integer
Capacity - 어레이리스트에 포함될수 있는 요소의 수를 불러온다. >> Integer
Item(Integer) - 지정된 인덱스에 있는 요소를 불러온다. >> Object
3. 함수
Add(object) - 개체를 끝에 추가
Clear() - 요소 모두 제거
Contains(object) - 요소가 어레이리스트에 있는지 확인
Remove(object) - 맨처음 발견되는 특정 개체를 삭제
Sort() - 전체 요소 정렬
2016년 10월 22일 토요일
2016년 7월 16일 토요일
c언어 자료구조 - 배열을 이용한 리스트2 (ArrayList.h )
2009.05.06
void add_last(ArrayListType *, element );
void add_first(ArrayListType *, element);
void clear(ArrayListType *);
void replace(ArrayListType *, position , element );
int is_in_list(ArrayListType *, element );
int get_length(ArrayListType *);
void ans(int);
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#define MAX_LIST_SIZE 100
typedef int element;
typedef int position;
typedef int position;
typedef struct{
int list[MAX_LIST_SIZE];
int length;
} ArrayListType;
int list[MAX_LIST_SIZE];
int length;
} ArrayListType;
void error(char *);
void init(ArrayListType *);
int is_empty(ArrayListType *);
int is_full(ArrayListType *);
void add(ArrayListType *, position, element);
//delete 대신 remove로 바꿈 <-- cpp에서는 delete 연산자가 정의되어 있기 때문에
element remove(ArrayListType *, position);
element get_entry(ArrayListType *, position);
void init(ArrayListType *);
int is_empty(ArrayListType *);
int is_full(ArrayListType *);
void add(ArrayListType *, position, element);
//delete 대신 remove로 바꿈 <-- cpp에서는 delete 연산자가 정의되어 있기 때문에
element remove(ArrayListType *, position);
element get_entry(ArrayListType *, position);
position first(ArrayListType *);
position last(ArrayListType *);
position before(ArrayListType *, position);
position after(ArrayListType *, position);
position last(ArrayListType *);
position before(ArrayListType *, position);
position after(ArrayListType *, position);
void add_last(ArrayListType *, element );
void add_first(ArrayListType *, element);
void clear(ArrayListType *);
void replace(ArrayListType *, position , element );
int is_in_list(ArrayListType *, element );
int get_length(ArrayListType *);
void ans(int);
c언어 자료구조 -배열을 이용한 리스트1 (ArrayList.cpp )
2009.05.06
#include "ArrayList.h"
void error(char *message)
{
fprintf(stderr,"%s\n", message);
exit(1); // exit 추가
{
fprintf(stderr,"%s\n", message);
exit(1); // exit 추가
}
void init(ArrayListType *L)
{
L->length = 0;
}
{
L->length = 0;
}
int is_empty(ArrayListType *L)
{
return L->length == 0;
}
{
return L->length == 0;
}
int is_full(ArrayListType *L)
{
return L->length == MAX_LIST_SIZE;
}
{
return L->length == MAX_LIST_SIZE;
}
void add(ArrayListType *L, position pos, element item)
{
int i;
{
int i;
if(!is_full(L) && (pos >= 0) && (pos <= L->length)){
for(i = (L->length - 1); i >= pos; i--){
L->list[i+1] = L->list[i];
}
L->list[pos] = item;
L->length++;
}
}
for(i = (L->length - 1); i >= pos; i--){
L->list[i+1] = L->list[i];
}
L->list[pos] = item;
L->length++;
}
}
element remove(ArrayListType *L, position pos)
{
int i;
element item;
{
int i;
element item;
if(pos < 0 || pos >= L->length){
error("위치오류");
}
item = L->list[pos];
for(i = pos; i < last(L); i++){
L->list[i] = L->list[i+1];
}
L->length--;
return item;
}
error("위치오류");
}
item = L->list[pos];
for(i = pos; i < last(L); i++){
L->list[i] = L->list[i+1];
}
L->length--;
return item;
}
position first(ArrayListType *L)
{
if(is_empty(L)){
error("list is empty");
return -1;
}
return 0;
}
{
if(is_empty(L)){
error("list is empty");
return -1;
}
return 0;
}
position last(ArrayListType *L)
{
if(is_empty(L)){
error("list is empty");
return -1;
}
return L->length - 1;
}
{
if(is_empty(L)){
error("list is empty");
return -1;
}
return L->length - 1;
}
position before(ArrayListType *L, position pos)
{
if(is_empty(L)){
error("list is empty");
return -1;
}
if(pos == first(L)){
error("current position is first");
return -1;
}
{
if(is_empty(L)){
error("list is empty");
return -1;
}
if(pos == first(L)){
error("current position is first");
return -1;
}
return pos - 1;
}
position after(ArrayListType *L, position pos)
{
if(is_empty(L)){
error("list is empty");
return -1;
}
if(pos == last(L)){
error("current position is last");
return -1;
}
{
if(is_empty(L)){
error("list is empty");
return -1;
}
if(pos == last(L)){
error("current position is last");
return -1;
}
return pos + 1;
}
}
element get_entry(ArrayListType *L, position pos)
{
if(is_empty(L) || (pos < first(L)) || (pos > last(L))){
error("position is out of range");
return -1;
}
return L->list[pos];
}
void add_last(ArrayListType *L, element item)
{
add(L,L->length,item);
{
if(is_empty(L) || (pos < first(L)) || (pos > last(L))){
error("position is out of range");
return -1;
}
return L->list[pos];
}
void add_last(ArrayListType *L, element item)
{
add(L,L->length,item);
}
//add_first(list, item) ::= 맨끝에 요소를 추가한다.
void add_first(ArrayListType *L, element item)
{
add(L,0,item);
void add_first(ArrayListType *L, element item)
{
add(L,0,item);
}
//clear(list) ::= 리스트의 모든 요소를 제거한다.
void clear(ArrayListType *L)
{
L->length=NULL;
free(L->list);
void clear(ArrayListType *L)
{
L->length=NULL;
free(L->list);
}
//replace(list, pos, item) ::= pos 위치의 요소를 item로 바꾼다
void replace(ArrayListType *L, position pos, element item)
{
L->list[pos]=item;
void replace(ArrayListType *L, position pos, element item)
{
L->list[pos]=item;
}
//is_in_list(list, item) ::= item이 리스트안에 있는지를 검사한다.
int is_in_list(ArrayListType *L, element wts)
{
int i;
for(i=0;i<L->length;i++){
if(L->list[i]==wts){
return 1;}}
return 0;
int is_in_list(ArrayListType *L, element wts)
{
int i;
for(i=0;i<L->length;i++){
if(L->list[i]==wts){
return 1;}}
return 0;
}
//get_length(list) ::= 리스트의 길이를 구한다.
int get_length(ArrayListType *L)
{
return L->length;
{
return L->length;
}
void ans(int n)
{
if(n){
printf("예!!!그렇습니다!!\n");}
else{
printf("아니요... 그렇지 않습니당...\n");}
}
{
if(n){
printf("예!!!그렇습니다!!\n");}
else{
printf("아니요... 그렇지 않습니당...\n");}
}
피드 구독하기:
글 (Atom)