- ActionsCript 작업중 , hashmap를 이용할 일이 었어서 검색을 하던 중 발견 하여 . 올려 봅니다.
class com.lib.data.holder.map.HashMap
{
public var keys:Array;
public var values:Array;
//
public function HashMap(source)
{
super();
this.keys = new Array();
this.values = new Array();
this.populate(source);
}
public function populate(source)
{
if (source)
{
for (var i in source)
{
this.put(i, source[i]);
}
}
}
public function containsKey(key)
{
return (this.findKey(key) > -1);
}
public function containsValue(value)
{
return (this.findValue(value) > -1);
}
public function getKeys(Void)
{
return (this.keys.slice());
}
public function getValues(Void)
{
return (this.values.slice());
}
public function get(key)
{
return (values[this.findKey(key)]);
}
public function put(key, value)
{
var oldKey;
var theKey = this.findKey(key);
if (theKey < 0)
{
this.keys.push(key);
this.values.push(value);
}
else
{
oldKey = values[theKey];
this.values[theKey] = value;
}
return (oldKey);
}
public function putAll(map)
{
var theValues = map.getValues();
var theKeys = map.getKeys();
var max = keys.length;
for (var i = 0; i < max; i = i - 1)
{
this.put(theKeys[i], theValues[i]);
}
}
public function clear(Void)
{
this.keys = new Array();
this.values = new Array();
}
public function remove(key)
{
var theKey = this.findKey(key);
if (theKey > -1)
{
var theValue = this.values[theKey];
this.values.splice(theKey, 1);
this.keys.splice(theKey, 1);
return (theValue);
}
}
public function size(Void)
{
return (this.keys.length);
}
public function isEmpty(Vois)
{
return (this.size() < 1);
}
public function findKey(key)
{
var index = this.keys.length;
while(this.keys[--index] !== key && index > -1)
{
}
return(index);
}
public function findValue(value)
{
var index = this.values.length;
while(this.values[--index] !== value && index > -1)
{
}
return (index);
}
}
##사용방법##
import com.lib.data.holder.map.*;
/* Add John to your `contact` list */
var myContacts:HashMap = new HashMap();
myContacts.put("John", new HashMap());
/* Get John, and add a `contacts` list */
var contact:HashMap = myContacts.get("John");
contact.put("contacts", new HashMap());
/* Add Johns contacts to the list */
var theContacts:HashMap = contact.get("contacts");
theContacts.put(0, "Mary");
theContacts.put(1, "Alex");
theContacts.put(2, "Julie");
/* Is Alex a contact of John? */
var isContact = myContacts.get("John").get("contacts").containsValue("Alex");
if (isContact) trace("Alex is contact of John");
else trace("Alex is Not a contact of John");
/* Is Mark a contact of John? */
var isContact = myContacts.get("John").get("contacts").containsValue("Mark");
if (isContact) trace("Mark is contact of John");
else trace("Mark is Not a contact of John");
/* Add John to your `contact` list */
var myContacts:HashMap = new HashMap();
myContacts.put("John", new HashMap());
/* Get John, and add a `contacts` list */
var contact:HashMap = myContacts.get("John");
contact.put("contacts", new HashMap());
/* Add Johns contacts to the list */
var theContacts:HashMap = contact.get("contacts");
theContacts.put(0, "Mary");
theContacts.put(1, "Alex");
theContacts.put(2, "Julie");
/* Is Alex a contact of John? */
var isContact = myContacts.get("John").get("contacts").containsValue("Alex");
if (isContact) trace("Alex is contact of John");
else trace("Alex is Not a contact of John");
/* Is Mark a contact of John? */
var isContact = myContacts.get("John").get("contacts").containsValue("Mark");
if (isContact) trace("Mark is contact of John");
else trace("Mark is Not a contact of John");
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 4630 | 13년 전 | 1189 | ||
| 4629 | 13년 전 | 4362 | ||
| 4628 | 13년 전 | 766 | ||
| 4627 |
|
13년 전 | 1754 | |
| 4626 | 13년 전 | 810 | ||
| 4625 |
마릴릴모니
|
13년 전 | 723 | |
| 4624 | 13년 전 | 1634 | ||
| 4623 |
SIR정회원
|
13년 전 | 602 | |
| 4622 |
rakoos
|
13년 전 | 1571 | |
| 4621 | 13년 전 | 676 | ||
| 4620 | 13년 전 | 1458 | ||
| 4619 | 13년 전 | 983 | ||
| 4618 | 13년 전 | 4032 | ||
| 4617 | 13년 전 | 2031 | ||
| 4616 | 13년 전 | 853 | ||
| 4615 | 13년 전 | 677 | ||
| 4614 | 13년 전 | 1244 | ||
| 4613 | 13년 전 | 880 | ||
| 4612 |
rakoos
|
13년 전 | 1019 | |
| 4611 |
|
13년 전 | 2108 | |
| 4610 | 13년 전 | 765 | ||
| 4609 | 13년 전 | 2818 | ||
| 4608 | 13년 전 | 2800 | ||
| 4607 | 13년 전 | 1073 | ||
| 4606 | 13년 전 | 771 | ||
| 4605 | 13년 전 | 2316 | ||
| 4604 | 13년 전 | 889 | ||
| 4603 | 13년 전 | 1141 | ||
| 4602 |
한번잘해보자
|
13년 전 | 677 | |
| 4601 | 13년 전 | 1803 | ||
| 4600 |
|
13년 전 | 1087 | |
| 4599 |
크라운엠버서더
|
13년 전 | 1151 | |
| 4598 | 13년 전 | 1500 | ||
| 4597 | 13년 전 | 592 | ||
| 4596 | 13년 전 | 3659 | ||
| 4595 |
|
13년 전 | 906 | |
| 4594 | 13년 전 | 1785 | ||
| 4593 | 13년 전 | 1278 | ||
| 4592 | 13년 전 | 655 | ||
| 4591 | 13년 전 | 4644 | ||
| 4590 | 13년 전 | 514 | ||
| 4589 | 13년 전 | 2631 | ||
| 4588 |
|
13년 전 | 989 | |
| 4587 | 13년 전 | 645 | ||
| 4586 |
JavaDD
|
13년 전 | 1013 | |
| 4585 | 13년 전 | 7778 | ||
| 4584 | 13년 전 | 972 | ||
| 4583 |
PHPㅡASP프로그래머
|
13년 전 | 2060 | |
| 4582 |
PHPㅡASP프로그래머
|
13년 전 | 1498 | |
| 4581 |
PHPㅡASP프로그래머
|
13년 전 | 1021 | |
| 4580 | 13년 전 | 4084 | ||
| 4579 |
|
13년 전 | 688 | |
| 4578 | 13년 전 | 1187 | ||
| 4577 | 13년 전 | 810 | ||
| 4576 |
Kanzi
|
13년 전 | 865 | |
| 4575 |
|
13년 전 | 1547 | |
| 4574 | 13년 전 | 2341 | ||
| 4573 |
달빛소나타
|
13년 전 | 875 | |
| 4572 | 13년 전 | 994 | ||
| 4571 | 13년 전 | 938 | ||
| 4570 |
|
13년 전 | 1306 | |
| 4569 |
한번잘해보자
|
13년 전 | 553 | |
| 4568 |
Raizond
|
13년 전 | 1018 | |
| 4567 |
Raizond
|
13년 전 | 522 | |
| 4566 |
Revenge
|
13년 전 | 941 | |
| 4565 |
|
13년 전 | 693 | |
| 4564 |
|
13년 전 | 1138 | |
| 4563 | 13년 전 | 1560 | ||
| 4562 | 13년 전 | 1208 | ||
| 4561 | 13년 전 | 9392 | ||
| 4560 | 13년 전 | 1771 | ||
| 4559 | 13년 전 | 3344 | ||
| 4558 | 13년 전 | 468 | ||
| 4557 | 13년 전 | 1446 | ||
| 4556 | 13년 전 | 700 | ||
| 4555 | 13년 전 | 548 | ||
| 4554 | 13년 전 | 541 | ||
| 4553 |
|
13년 전 | 4307 | |
| 4552 | 13년 전 | 1508 | ||
| 4551 | 13년 전 | 1994 | ||
| 4550 | 13년 전 | 680 | ||
| 4549 | 13년 전 | 1036 | ||
| 4548 | 13년 전 | 1571 | ||
| 4547 | 13년 전 | 554 | ||
| 4546 | 13년 전 | 1616 | ||
| 4545 | 13년 전 | 1332 | ||
| 4544 | 13년 전 | 3023 | ||
| 4543 | 13년 전 | 1012 | ||
| 4542 | 13년 전 | 2263 | ||
| 4541 | 13년 전 | 1137 | ||
| 4540 |
|
13년 전 | 1060 | |
| 4539 | 13년 전 | 1155 | ||
| 4538 | 13년 전 | 1586 | ||
| 4537 | 13년 전 | 1172 | ||
| 4536 | 13년 전 | 547 | ||
| 4535 |
|
13년 전 | 822 | |
| 4534 |
|
13년 전 | 981 | |
| 4533 | 13년 전 | 646 | ||
| 4532 |
soing
|
13년 전 | 7376 | |
| 4531 |
|
13년 전 | 6395 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기