- 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");
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 3930 | 14년 전 | 1352 | ||
| 3929 |
방황하는중년
|
14년 전 | 525 | |
| 3928 | 14년 전 | 638 | ||
| 3927 | 14년 전 | 691 | ||
| 3926 |
Lemios
|
14년 전 | 710 | |
| 3925 | 14년 전 | 991 | ||
| 3924 |
|
14년 전 | 1039 | |
| 3923 | 14년 전 | 1613 | ||
| 3922 | 14년 전 | 633 | ||
| 3921 |
피디인사이드
|
14년 전 | 1080 | |
| 3920 |
wgarlic
|
14년 전 | 2869 | |
| 3919 |
또치2009
|
14년 전 | 793 | |
| 3918 | 14년 전 | 747 | ||
| 3917 |
|
14년 전 | 1181 | |
| 3916 | 14년 전 | 1174 | ||
| 3915 | 14년 전 | 2020 | ||
| 3914 | 14년 전 | 1232 | ||
| 3913 | 14년 전 | 608 | ||
| 3912 | 14년 전 | 548 | ||
| 3911 | 14년 전 | 465 | ||
| 3910 | 14년 전 | 671 | ||
| 3909 | 14년 전 | 2187 | ||
| 3908 | 14년 전 | 622 | ||
| 3907 | 14년 전 | 646 | ||
| 3906 | 14년 전 | 741 | ||
| 3905 | 14년 전 | 944 | ||
| 3904 |
후라보노보노
|
14년 전 | 589 | |
| 3903 | 14년 전 | 869 | ||
| 3902 | 14년 전 | 1430 | ||
| 3901 |
fstjang
|
14년 전 | 664 | |
| 3900 | 14년 전 | 989 | ||
| 3899 |
|
14년 전 | 437 | |
| 3898 | 14년 전 | 504 | ||
| 3897 | 14년 전 | 981 | ||
| 3896 | 14년 전 | 1331 | ||
| 3895 | 14년 전 | 1418 | ||
| 3894 | 14년 전 | 884 | ||
| 3893 | 14년 전 | 810 | ||
| 3892 |
|
14년 전 | 1334 | |
| 3891 | 14년 전 | 857 | ||
| 3890 | 14년 전 | 3952 | ||
| 3889 | 14년 전 | 1885 | ||
| 3888 | 14년 전 | 680 | ||
| 3887 | 14년 전 | 601 | ||
| 3886 | 14년 전 | 3542 | ||
| 3885 |
후라보노보노
|
14년 전 | 4241 | |
| 3884 | 14년 전 | 979 | ||
| 3883 | 14년 전 | 1162 | ||
| 3882 | 14년 전 | 4399 | ||
| 3881 |
minini
|
14년 전 | 1218 | |
| 3880 | 14년 전 | 995 | ||
| 3879 | 14년 전 | 744 | ||
| 3878 | 14년 전 | 764 | ||
| 3877 |
내꿈은대통령
|
14년 전 | 951 | |
| 3876 | 14년 전 | 880 | ||
| 3875 | 14년 전 | 1031 | ||
| 3874 | 14년 전 | 908 | ||
| 3873 | 14년 전 | 1330 | ||
| 3872 |
뜨드미지근
|
14년 전 | 677 | |
| 3871 |
SW커뮤니케이션
|
14년 전 | 535 | |
| 3870 |
방황하는중년
|
14년 전 | 560 | |
| 3869 | 14년 전 | 709 | ||
| 3868 | 14년 전 | 1173 | ||
| 3867 |
방황하는중년
|
14년 전 | 814 | |
| 3866 |
웹스커뮤니티
|
14년 전 | 1354 | |
| 3865 | 14년 전 | 1109 | ||
| 3864 |
|
14년 전 | 1080 | |
| 3863 | 14년 전 | 1052 | ||
| 3862 |
|
14년 전 | 1919 | |
| 3861 |
|
14년 전 | 3238 | |
| 3860 | 14년 전 | 1447 | ||
| 3859 | 14년 전 | 2385 | ||
| 3858 |
웹스커뮤니티
|
14년 전 | 1891 | |
| 3857 | 14년 전 | 1773 | ||
| 3856 |
크라잉감튀
|
14년 전 | 951 | |
| 3855 |
techer
|
14년 전 | 491 | |
| 3854 |
techer
|
14년 전 | 774 | |
| 3853 |
techer
|
14년 전 | 933 | |
| 3852 |
디자이너몽
|
14년 전 | 1651 | |
| 3851 | 14년 전 | 1710 | ||
| 3850 | 14년 전 | 1136 | ||
| 3849 | 14년 전 | 784 | ||
| 3848 | 14년 전 | 1004 | ||
| 3847 | 14년 전 | 1035 | ||
| 3846 | 14년 전 | 1050 | ||
| 3845 | 14년 전 | 582 | ||
| 3844 |
풍객리무진짱
|
14년 전 | 654 | |
| 3843 | 14년 전 | 769 | ||
| 3842 | 14년 전 | 1719 | ||
| 3841 | 14년 전 | 915 | ||
| 3840 | 14년 전 | 858 | ||
| 3839 | 14년 전 | 1149 | ||
| 3838 |
xkingcode
|
14년 전 | 760 | |
| 3837 | 14년 전 | 914 | ||
| 3836 | 14년 전 | 864 | ||
| 3835 |
temptiger
|
14년 전 | 1148 | |
| 3834 | 14년 전 | 694 | ||
| 3833 | 14년 전 | 705 | ||
| 3832 | 14년 전 | 613 | ||
| 3831 | 14년 전 | 725 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기