분류 전체보기98 [자료구조] HashTable - HashMap과 구조가 비슷하지만 용도가 다르다. - 키와 값을 1:1형태로 가져간다. - 동기화가 이루어진다. - null 입력이 불가능하다. 선언 import java.util.Hashtable; public class HashTableDemo { public static void main(String[] arg) { Hashtable ht = new Hashtable(); // 타입 설정x Object 설정 Hashtable i = new Hashtable(); // Integer, Integer 타입 선언 Hashtable i2 = new Hashtable(); // new는 타입 생략 가능 Hashtable i3 = new Hashtable(i); // i의 Hashtable을 i3으로 값 .. 2023. 11. 9. [JavaScript] Array.from()통해 배열 만들기 Array.from()은 문자열등 이터러블한 객체나 유사 배열 새로운 배열로 만들어주는 메서드이다. - 이터러블(iterable)은 Symbol.iterator가 구현된 객체이다. - 유사 배열(array-like)은 인덱스와 length 프로퍼티가 있어 배열처럼 보이는 객체이다. Array.from(인자 1, 인자 2) - 첫 번째 인자는 배열로 만들 이터러블한 객체이다. - 두 번째 객체는 생성한 배열의 모든 원소에 대해 수행할 맵핑 함수이다. 예시 console.log(Array.from("Eddy")); // ['E', 'd', 'd', 'y'] console.log(Array.from({length: 5}, (v, i) => i); // [0, 1, 2, 3, 4] console.log(Arra.. 2023. 11. 8. [자료구조] TreeSet - 데이터의 순서는 자연적인 순서(오름차순)대로 유지가 된다. - 이진 탐색 트리(Binary Search Tree) 구조로 되어있다. - 이진 탐색 트리 중에서도 레드-블랙 트리(Red-Black Tree)로 구현되어 있다. 생성 및 선언 import java.util.Collections; import java.util.TreeSet; public class TreeSetDemo{ public static void main(String[] args) { TreeSet set1 = new TreeSet(); // TreeSet 생성 TreeSet set2 = new TreeSet(); // new에서 타입 파라미터 생략가능 TreeSet set3 = new TreeSet(set1); // set1의 모.. 2023. 11. 7. [자료구조] Hash Set - 입력한 순서가 보장되지 않는다. - 중복된 값을 허용하지 않는다. - NULL 삽입이 가능하다. 생성 import java.util.HashSet; HashSet colors1 = new HashSet(); // 타입 지정 HashSet colors2 = new HashSet(); // 타입 생략 가능 HashSet colors3 = new HashSet(10); // 초기 용량(Capacity) 설정 HashSet colors4 = new HashSet(colors1); // 다른 Collection값으로 초기화 HashSet colors5 = new HashSet(Arrays.asList("Blue", "Black", "White")); // Arrays.asList() HashSet colors.. 2023. 11. 7. 이전 1 ··· 6 7 8 9 10 11 12 ··· 25 다음