Scripting Runtime Library(Dictionary)

Dictionary °³Ã¼¿¡¼­ Å°-Ç׸ñ ½ÖÀ» Çϳª Á¦°ÅÇÑ´Ù.

Àμö/ÆĶó¸ÞÅÍ
object
ÇʼöÀûÀÎ ¿ä¼ÒÀ̸ç, Ç×»ó Dictionary °³Ã¼ÀÇ À̸§ÀÌ´Ù.
key
ÇʼöÀûÀÎ ¿ä¼ÒÀ̸ç, Dictionary °³Ã¼¿¡¼­ Á¦°ÅÇÏ·Á´Â Å°-Ç׸ñ ½Ö°ú ¿¬°áµÈ KeyÀÌ´Ù.
¹Ýȯ°ª

¹Ýȯ°ªÀº ¾ø´Ù.

¼³¸í

Dictionary °³Ã¼¿¡¼­ Å°-Ç׸ñ ½ÖÀ» Çϳª Á¦°ÅÇÑ´Ù.

ÁöÁ¤ÇÑ Å°-Ç׸ñ ½ÖÀÌ ¾øÀ¸¸é ¿À·ù°¡ ¹ß»ýÇÑ´Ù.


Remove ¸Þ¼­µå ¿¹Á¦

°á°ú Ç¥½Ãâ
JScript Remove ¸Þ¼­µå ¿¹Á¦
<SCRIPT language=JScript>
function RemoveTest(key){
  var KeyArr,DicArr,dicObj,numb,str=''; // º¯¼ö¸¦ ¸¸µç´Ù.
  dicObj=new ActiveXObject('Scripting.Dictionary');
  dicObj.Add('a','»ç°ú'); // Å°¿Í Ç׸ñÀ» Ãß°¡ÇÑ´Ù.
  dicObj.Add('b','¹Ù³ª³ª');
  dicObj.Add('c','ü¸®');
  KeyArr=new VBArray(dicObj.Keys()).toArray(); // Key Ç׸ñÀ» °¡Á®¿Â´Ù.
  DicArr=new VBArray(dicObj.Items()).toArray(); // Ç׸ñÀ» °¡Á®¿Â´Ù.
  for (numb in DicArr){ // dictionary¸¦ ¹Ýº¹ÇÑ´Ù.
    str+=numb+') "'+KeyArr[numb]+'"='+DicArr[numb]+'<BR>';
  }
  str+='dicObj.Count='+dicObj.Count+'<BR><BR>';

  dicObj.Remove(key); // µÎ ¹ø° ½ÖÀ» Á¦°ÅÇÑ´Ù.
  str+='dicObj.Remove(key)<BR>';
  KeyArr=new VBArray(dicObj.Keys()).toArray(); // Key Ç׸ñÀ» °¡Á®¿Â´Ù.
  DicArr=new VBArray(dicObj.Items()).toArray(); // Ç׸ñÀ» °¡Á®¿Â´Ù.
  for (numb in DicArr){ // dictionary¸¦ ¹Ýº¹ÇÑ´Ù.
    str+=numb+') "'+KeyArr[numb]+'"='+DicArr[numb]+'<BR>';
  }
  str+='dicObj.Count='+dicObj.Count;
  return(str);
}
</SCRIPT>

<DIV id=showjs class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV>
<DIV class=show onClick="id=showjs.innerHTML=RemoveTest('b')">
  <SPAN class=ie>JScript</SPAN> <SPAN class=method>Remove</SPAN> ¸Þ¼­µå ¿¹Á¦</DIV>
°á°ú Ç¥½Ãâ
VBScript Remove ¸Þ¼­µå ¿¹Á¦
<SCRIPT language=VBScript>
Function RemoveTestvb(key)
  Dim KeyArr,DicArr,dicObj,numb ' º¯¼ö¸¦ ¸¸µç´Ù.
  str=""
  Set dicObj=CreateObject("Scripting.Dictionary")
  dicObj.Add "a","»ç°ú" ' Å°¿Í Ç׸ñÀ» Ãß°¡ÇÑ´Ù.
  dicObj.Add "b","¹Ù³ª³ª"
  dicObj.Add "c","ü¸®"

  KeyArr=DicObj.Keys ' Å°¸¦ °¡Á®¿Â´Ù.
  DicArr=DicObj.Items ' Ç׸ñÀ» °¡Á®¿Â´Ù.
  For numb=0 To DicObj.Count-1 ' dictionary¸¦ ¹Ýº¹ÇÑ´Ù.
    str=str&"'"&KeyArr(numb)&"' : "&DicArr(numb)&"<BR>" ' °á°ú¸¦ ¹ÝȯÇÑ´Ù.
  Next
  str=str&"dicObj.Count="&dicObj.Count&"<BR><BR>"

  str=str&"dicObj.Remove(key)<BR>"
  dicObj.Remove(key) ' µÎ ¹ø° ½ÖÀ» Á¦°ÅÇÑ´Ù.
  DicArr=DicObj.Keys ' Å°¸¦ °¡Á®¿Â´Ù.
  For numb=0 To DicObj.Count-1 ' dictionary¸¦ ¹Ýº¹ÇÑ´Ù.
    str=str&"'"&DicArr(numb)&"' : "&DicObj.Item(DicArr(numb))&"<BR>" ' °á°ú¸¦ ¹ÝȯÇÑ´Ù.
  Next
  str=str&"dicObj.Count="&dicObj.Count

  RemoveTestvb=str
End Function
</SCRIPT>

<DIV id=showvb class=show alt="°á°ú">°á°ú Ç¥½Ãâ</DIV>
<DIV class=show onClick="showvb.innerHTML=RemoveTestvb('b')">
  <SPAN class=ie>VBScript</SPAN> <SPAN class=method>Remove</SPAN> ¸Þ¼­µå ¿¹Á¦</DIV>