|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| ÀÌÀü Ŭ·¡½º ´ÙÀ½ Ŭ·¡½º | ÇÁ·¹ÀÓÀ¸·Î ÇÁ·¹ÀÓ ¾øÀÌ | |||||||||
| °³¿ä: NESTED | Çʵå | constructor | ¸Þ¼µå | »ó¼¼: Çʵå | »ý¼ºÀÚ | ¸Þ¼µå | |||||||||
java.lang.Objectjava.util.BitSet
public class BitSet
ÀÌ Å¬·¡½º´Â Çʿ信 µû¶ó¼ Ä¿Áö´Â ºñÆ® º¤Å͸¦ ±¸ÇöÇÕ´Ï´Ù. ºñÆ® ¼¼Æ®ÀÇ °¢ ¿ä¼Ò´Â boolean°ªÀ» °¡Áý´Ï´Ù. BitSet
ºñÆ®¿¡´Â ºÎ°¡ ¾Æ´Ñ Á¤¼öÀÇ À妽º¸¦ ºÙÀÏ ¼ö ÀÖ½À´Ï´Ù. À妽º¸¦ ºÙÀÏ ¼ö ÀÖ´ø °³º°ÀÇ ºñÆ®´Â ½ÃÇèÇϰųª ¼³Á¤Çϰųª Ŭ¸®¾î Çϰųª ÇÒ ¼ö ÀÖ½À´Ï´Ù. ¶Ç, ³í¸®Àû, Æ÷ÇÔÀû ³í¸®ÇÕ ¹× ¹èŸÀû ³í¸®ÇÕÀÇ ¿¬»êÀ» ½Ç½ÃÇϸé, ¾î´À BitSet¸¦ »ç¿ëÇØ ´Ù¸¥ BitSet
³»¿ëÀ» º¯°æÇÒ ¼ö ÀÖ½À´Ï´Ù.
µðÆúÆ®¿¡¼´Â ¼¼Æ®ÀÇ ¸ðµç ºñÆ®´Â ÃʱⰪÀ¸·Î
false¸¦ °¡Áý´Ï´Ù.
ºñÆ® ¼¼Æ®ÀÇ, ÇöÀçÀÇ »çÀÌÁî´Â ±× ºñÆ® ¼¼Æ®¿¡ ÀÇÇØ ÇöÀç »ç¿ëµÇ°í ÀÖ´Â ½ºÆäÀ̽ºÀÇ ºñÆ®¼öÀÔ´Ï´Ù. ÀÌ »çÀÌÁî´Â ºñÆ® ¼¼Æ®ÀÇ ±¸Çö°ú °ü·ÃÇϹǷΠ»çÀÌÁî´Â ±¸Çö¿¡ ÀÇÇØ ¹Ù²î´Â °æ¿ì°¡ ÀÖ½À´Ï´Ù. ºñÆ® ¼¼Æ®ÀÇ ±æÀÌ´Â ºñÆ® ¼¼Æ®ÀÇ ³í¸®ÀûÀÎ ±æÀÌ¿Í °ü·ÃÇØ, ±¸Çö°ú´Â °ü°è¾øÀÌ Á¤Àǵ˴ϴÙ.
ƯÈ÷ ¸í±âµÇ¾î ÀÖÁö ¾ÊÀº ÇÑ, null ÆÄ¶ó¹ÌÅ͸¦ BitSet
¸Þ¼µå¿¡ °Ç³×ÁÖ¸é, NullPointerException°¡ ¹ß»ý µË´Ï´Ù.
BitSetÀÌ
¿ÜºÎÀÇ µ¿±âȸ¦ ½Ç½ÃÇÏÁö ¾Ê°í multi-thread¸¦ »ç¿ëÇÏ´Â °ÍÀº ¾ÈÀüÇÏÁö´Â ¾Ê½À´Ï´Ù.
| »ý¼ºÀÚ °³¿ä | |
|---|---|
BitSet ()
»õ·Î¿î ºñÆ® ¼¼Æ®¸¦ ÀÛ¼ºÇÕ´Ï´Ù. |
|
BitSet (int nbits)
0 ~ nbits-1
¹üÀ§ÀÇ À妽º¸¦ °¡Áö´Â ºñÆ®¸¦ ¸í½ÃÀûÀ¸·Î ³ªÅ¸³»±â À§Çؼ ÃæºÐÇÑ Ãʱ⠻çÀÌÁ °¡Áö´Â ºñÆ® ¼¼Æ®¸¦ ÀÛ¼ºÇÕ´Ï´Ù. |
|
| ¸Þ¼µå °³¿ä | |
|---|---|
void |
and (BitSet set)
Ÿ°Ù ºñÆ® ¼¼Æ®¿Í Àμö ºñÆ® ¼¼Æ®ÀÇ ³í¸®Ã÷¹«¸¦ Àâ½À´Ï´Ù. |
void |
andNot (BitSet set)
´ëÀÀÇÏ´Â ºñÆ®°¡ ÁöÁ¤µÈ BitSet·Î
¼³Á¤µÇ¾î ÀÖ´Â BitSet
ºñÆ®¸¦ ¸ðµÎ Ŭ¸®¾î ÇÕ´Ï´Ù. |
int |
cardinality ()
ÀÌ BitSet·Î
true·Î
¼³Á¤µÈ ºñÆ®ÀÇ ¼ö¸¦ ¸®ÅÏÇÕ´Ï´Ù. |
void |
clear ()
ÀÌ BitSet ºñÆ®¸¦ ¸ðµÎ false·Î
¼³Á¤ÇÕ´Ï´Ù. |
void |
clear (int bitIndex)
À妽º·Î ÁöÁ¤µÈ ºñÆ®¸¦ false·Î
¼³Á¤ÇÕ´Ï´Ù. |
void |
clear (int fromIndex,
int toIndex)
ÁöÁ¤µÈ fromIndex(inclusive)·ÎºÎÅÍ ÁöÁ¤µÈ toIndex(exclusive)±îÁö, ºñÆ®¸¦ false·Î
¼³Á¤ÇÕ´Ï´Ù. |
Object |
clone ()
BitSet¸¦ º¹Á¦ÇÏ´Â °ÍÀ¸·Î µ¿µîÇÑ »õ·Î¿î BitSet¸¦ ÀÛ¼ºÇÕ´Ï´Ù. |
boolean |
equals (Object obj)
°´Ã¼¿Í ÁöÁ¤µÈ °´Ã¼¸¦ ºñ±³ÇÕ´Ï´Ù. |
void |
flip (int bitIndex)
ÇöÀç°¡ÀÇ º¸¼ö·Î ÁöÁ¤µÈ À妽ºÀÇ ºñÆ®¸¦ ¼³Á¤ÇÕ´Ï´Ù. |
void |
flip (int fromIndex,
int toIndex)
ÁöÁ¤µÈ fromIndex(inclusive)·ÎºÎÅÍ ÁöÁ¤µÈ toIndex(exclusive)±îÁö, °¢ ºñÆ®¸¦ ±× ÇöÀç°¡ÀÇ º¸¼ö·Î ¼³Á¤ÇÕ´Ï´Ù. |
boolean |
get (int bitIndex)
ÁöÁ¤µÈ À妽º¸¦ °¡Áö´Â ºñÆ®ÀÇ °ªÀ» ¸®ÅÏÇÕ´Ï´Ù. |
BitSet |
get (int fromIndex,
int toIndex)
ÀÌ BitSet·Î ºÎÅÍÀÇ ºñÆ®·Î ±¸¼ºµÇ´Â »õ·Î¿î BitSet¸¦ fromIndex (ÀÌ °ªÀ» Æ÷ÇÔÇÑ´Ù)·ÎºÎÅÍ toIndex(ÀÌ °ªÀ» Æ÷ÇÔÇÏÁö ¾Ê´Â´Ù)±îÁö ¸®ÅÏÇÕ´Ï´Ù. |
int |
hashCode ()
ºñÆ® ¼¼Æ®ÀÇ ÇØ½Ã Äڵ尪À» ¸®ÅÏÇÕ´Ï´Ù. |
boolean |
intersects (BitSet set)
ÀÌ BitSet¿¡
¼µµ true·Î
¼³Á¤µÈ, true ¼³Á¤ÀÇ ºñÆ®°¡ ÁöÁ¤µÈ BitSet¿¡ ÀÖ´Â °æ¿ì, true¸¦ ¸®ÅÏÇÕ´Ï´Ù. |
boolean |
isEmpty ()
ÀÌ BitSet¿¡ true·Î
¼³Á¤µÈ ºñÆ®°¡ Æ÷ÇÔµÇÁö ¾ÊÀº °æ¿ì´Â true¸¦ ¸®ÅÏÇÕ´Ï´Ù. |
int |
length ()
BitSet
¡¸³í¸® »çÀÌÁ, Áï BitSet
ÃÖ»óÁ¤µµ ¼¼Æ® ºñÆ®ÀÇ À妽º¿¡ 1À» ´õÇÑ °ªÀ» ¸®ÅÏÇÕ´Ï´Ù. |
int |
nextClearBit (int fromIndex)
ÁöÁ¤µÈ °³½Ã À妽º½Ã, ¶Ç´Â ±× À妽º ÈÄ¿¡ »ý±â´Â false·Î
¼³Á¤µÈ ÃÖÃÊÀÇ ºñÆ®ÀÇ À妽º¸¦ ¸®ÅÏÇÕ´Ï´Ù. |
int |
nextSetBit (int fromIndex)
ÁöÁ¤µÈ °³½Ã À妽º½Ã, ¶Ç´Â ±× À妽º ÈÄ¿¡ »ý±â´Â true·Î
¼³Á¤µÈ ÃÖÃÊÀÇ ºñÆ®ÀÇ À妽º¸¦ ¸®ÅÏÇÕ´Ï´Ù. |
void |
or (BitSet set)
ºñÆ® ¼¼Æ®¿Í ºñÆ® ¼¼Æ® ÀμöÀÇ ³í¸®ÇÕÀ» ÃëÇÕ´Ï´Ù. |
void |
set (int bitIndex)
ÁöÁ¤µÈ À妽ºÀÇ ºñÆ®¸¦ true·Î
¼³Á¤ÇÕ´Ï´Ù. |
void |
set (int bitIndex,
boolean value)
ÁöÁ¤µÈ À妽ºÀÇ ºñÆ®°¡ ÁöÁ¤µÈ °ªÀ¸·Î ¼³Á¤ÇÕ´Ï´Ù. |
void |
set (int fromIndex,
int toIndex)
ÁöÁ¤µÈ fromIndex(inclusive)·ÎºÎÅÍ ÁöÁ¤µÈ toIndex(exclusive)±îÁö, ºñÆ®¸¦ true·Î
¼³Á¤ÇÕ´Ï´Ù. |
void |
set (int fromIndex,
int toIndex,
boolean value)
ÁöÁ¤µÈ fromIndex(inclusive)·ÎºÎÅÍ ÁöÁ¤µÈ toIndex(exclusive)±îÁö, ºñÆ®°¡ ÁöÁ¤µÈ °ªÀ¸·Î ¼³Á¤ÇÕ´Ï´Ù. |
int |
size ()
BitSet·Î
ºñƮġ¸¦ ³ªÅ¸³»±â À§Çؼ ½ÇÁ¦·Î »ç¿ëÇϰí ÀÖ´Â ºñÆ®ÀÇ ¼ö¸¦ ¸®ÅÏÇÕ´Ï´Ù. |
String |
toString ()
ºñÆ® ¼¼Æ®ÀÇ Ä³¸¯ÅÍ ¶óÀΠǥÇöÀ» ¸®ÅÏÇÕ´Ï´Ù. |
void |
xor (BitSet set)
ºñÆ® ¼¼Æ®¿Í ºñÆ® ¼¼Æ® ÀμöÀÇ ¹èŸÀû ³í¸®ÇÕÀ» ÃëÇÕ´Ï´Ù. |
| Ŭ·¡½º java.lang. Object ·ÎºÎÅÍ »ó¼ÓµÈ ¸Þ¼µå |
|---|
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
| »ý¼ºÀÚ »ó¼¼ |
|---|
public BitSet()
false ÀÔ´Ï´Ù.
public BitSet(int nbits)
0 ~ nbits-1
¹üÀ§ÀÇ À妽º¸¦ °¡Áö´Â ºñÆ®¸¦ ¸í½ÃÀûÀ¸·Î ³ªÅ¸³»±â À§Çؼ ÃæºÐÇÑ Ãʱ⠻çÀÌÁ °¡Áö´Â ºñÆ® ¼¼Æ®¸¦ ÀÛ¼ºÇÕ´Ï´Ù. ºñÆ®ÀÇ ÃʱⰪ
´Â ¸ðµÎ false ÀÔ´Ï´Ù.
nbits - ºñÆ® ¼¼Æ®ÀÇ Ãʱ⠻çÀÌÁî
NegativeArraySizeException - ÁöÁ¤µÈ Ãʱ⠻çÀÌÁî°¡ ºÎÀÇ °æ¿ì| ¸Þ¼µåÀÇ »ó¼¼ |
|---|
public void flip(int bitIndex)
bitIndex - ¹ÝÀüÇÏ´Â ºñÆ®ÀÇ À妽º
IndexOutOfBoundsException - ÁöÁ¤µÈ À妽º°¡ ºÎÀÇ °æ¿ì
public void flip(int fromIndex,
int toIndex)
fromIndex - ¹ÝÀüÇÏ´Â ÃÖÃÊÀÇ ºñÆ®ÀÇ À妽ºtoIndex - ¹ÝÀüÇÏ´Â ¸¶Áö¸· ºñÆ®ÀÇ µÚÀÇ À妽º
IndexOutOfBoundsException - fromIndex°¡ À߸øµÈ °ª, ȤÀº toIndex°¡ À߸øµÈ °ª, ȤÀº fromIndex°¡ toIndex º¸´Ù Å« °æ¿ìpublic void set(int bitIndex)
true·Î
¼³Á¤ÇÕ´Ï´Ù.
bitIndex - ºñÆ® À妽º
IndexOutOfBoundsException - ÁöÁ¤µÈ À妽º°¡ ºÎÀÇ °æ¿ì
public void set(int bitIndex,
boolean value)
bitIndex - ºñÆ® À妽ºvalue - ¼³Á¤µÇ´Â boolean Ä¡
IndexOutOfBoundsException - ÁöÁ¤µÈ À妽º°¡ ºÎÀÇ °æ¿ì
public void set(int fromIndex,
int toIndex)
true·Î
¼³Á¤ÇÕ´Ï´Ù.
fromIndex - ¼³Á¤ÇÏ´Â ÃÖÃÊÀÇ ºñÆ®ÀÇ À妽ºtoIndex - ¼³Á¤µÇ´Â ¸¶Áö¸· ºñÆ®ÀÇ µÚÀÇ À妽º
IndexOutOfBoundsException - fromIndex°¡ À߸øµÈ °ª, ȤÀº toIndex°¡ À߸øµÈ °ª, ȤÀº fromIndex°¡ toIndex º¸´Ù Å« °æ¿ì
public void set(int fromIndex,
int toIndex,
boolean value)
fromIndex - ¼³Á¤ÇÏ´Â ÃÖÃÊÀÇ ºñÆ®ÀÇ À妽ºtoIndex - ¼³Á¤µÇ´Â ¸¶Áö¸· ºñÆ®ÀÇ µÚÀÇ À妽ºvalue - ¼±ÅÃµÈ ºñÆ®¸¦ ¼³Á¤ÇÏ´Â °ª
IndexOutOfBoundsException - fromIndex°¡ À߸øµÈ °ª, ȤÀº toIndex°¡ À߸øµÈ °ª, ȤÀº fromIndex°¡ toIndex º¸´Ù Å« °æ¿ìpublic void clear(int bitIndex)
false·Î
¼³Á¤ÇÕ´Ï´Ù.
bitIndex - Ŭ¸®¾î ÇÏ´Â ºñÆ®ÀÇ À妽º
IndexOutOfBoundsException - ÁöÁ¤µÈ À妽º°¡ ºÎÀÇ °æ¿ì
public void clear(int fromIndex,
int toIndex)
false·Î
¼³Á¤ÇÕ´Ï´Ù.
fromIndex - Ŭ¸®¾î ÇÏ´Â ÃÖÃÊÀÇ ºñÆ®ÀÇ À妽ºtoIndex - Ŭ¸®¾î µÇ´Â ¸¶Áö¸· ºñÆ®ÀÇ µÚÀÇ À妽º
IndexOutOfBoundsException - fromIndex°¡ À߸øµÈ °ª, ȤÀº toIndex°¡ À߸øµÈ °ª, ȤÀº fromIndex°¡ toIndex º¸´Ù Å« °æ¿ìpublic void clear()
false·Î
¼³Á¤ÇÕ´Ï´Ù.
public boolean get(int bitIndex)
BitSet¿¡ bitIndex
À妽º¸¦ °¡Áö´Â ºñÆ®°¡ ¼³Á¤µÇ¾î ÀÖ´Â °æ¿ì, °ªÀº true ÀÔ´Ï´Ù. ±×·¸Áö ¾ÊÀº °æ¿ì´Â false ÀÔ´Ï´Ù.
bitIndex - ºñÆ® À妽º
IndexOutOfBoundsException - ÁöÁ¤µÈ À妽º°¡ ºÎÀÇ °æ¿ì
public BitSet get(int fromIndex,
int toIndex)
fromIndex - Â¥³Ö´Â ÃÖÃÊÀÇ ºñÆ®ÀÇ À妽ºtoIndex - Â¥³Ö´Â ¸¶Áö¸· ºñÆ®ÀÇ µÚÀÇ À妽º
IndexOutOfBoundsException - fromIndex°¡ À߸øµÈ °ª, ȤÀº toIndex°¡ À߸øµÈ °ª, ȤÀº fromIndex°¡ toIndex º¸´Ù Å« °æ¿ìpublic int nextSetBit(int fromIndex)
true·Î
¼³Á¤µÈ ÃÖÃÊÀÇ ºñÆ®ÀÇ À妽º¸¦ ¸®ÅÏÇÕ´Ï´Ù. ÇØ´çÇÏ´Â ºñÆ®°¡ Á¸ÀçÇÏÁö ¾Ê´Â °æ¿ì´Â -1 ÀÌ ¸®Åϵ˴ϴÙ
.
BitSet ³»ÀÇ true ºñÆ®¿¡ ´ëÇØ¼ ¹Ýº¹ 󸮸¦ ½ÇÇàÇÏ´Â °æ¿ì´Â
for(int i=bs.nextSetBit(0); i>=0; i=bs.nextSetBit(i+1)) { // operate on index i here } ·çÇÁ¸¦ »ç¿ëÇÕ´Ï´Ù.
fromIndex - üũ¸¦ °³½ÃÇÏ´Â À§Ä¡ÀÇ À妽º (±× °ªµµ Æ÷ÇÔÇÑ´Ù)
IndexOutOfBoundsException - ÁöÁ¤µÈ À妽º°¡ ºÎÀÇ °æ¿ìpublic int nextClearBit(int fromIndex)
false·Î
¼³Á¤µÈ ÃÖÃÊÀÇ ºñÆ®ÀÇ À妽º¸¦ ¸®ÅÏÇÕ´Ï´Ù.
fromIndex - üũ¸¦ °³½ÃÇÏ´Â À§Ä¡ÀÇ À妽º (±× °ªµµ Æ÷ÇÔÇÑ´Ù)
IndexOutOfBoundsException - ÁöÁ¤µÈ À妽º°¡ ºÎÀÇ °æ¿ìpublic int length()
BitSet
¡¸³í¸® »çÀÌÁ, Áï BitSet
ÃÖ»óÁ¤µµ ¼¼Æ® ºñÆ®ÀÇ À妽º¿¡ 1À» ´õÇÑ °ªÀ» ¸®ÅÏÇÕ´Ï´Ù. BitSet¿¡ ¼¼Æ® ºñÆ®°¡ ¾ø´Â °æ¿ì´Â Á¦·Î¸¦ ¸®ÅÏÇÕ´Ï´Ù.
BitSet
³í¸® »çÀÌÁîpublic boolean isEmpty()
BitSet¿¡ true·Î
¼³Á¤µÈ ºñÆ®°¡ Æ÷ÇÔµÇÁö ¾ÊÀº °æ¿ì´Â true¸¦ ¸®ÅÏÇÕ´Ï´Ù.
BitSetÀÌ ºñ¾îÀÖ´ÂÁö ³ªÅ¸³»´Â boolean Çüpublic boolean intersects(BitSet set)
BitSet¿¡
¼µµ true·Î
¼³Á¤µÈ, true ¼³Á¤ÀÇ ºñÆ®°¡ ÁöÁ¤µÈ BitSet¿¡ ÀÖ´Â °æ¿ì, true¸¦ ¸®ÅÏÇÕ´Ï´Ù.
set - ±³Â÷ÇÏ´Â BitSet
BitSetÀÌ ÁöÁ¤µÈ BitSet¿Í
±³Â÷ÇÒÁö ¾î¶³Áö¸¦ ³ªÅ¸³»´Â boolean Çüpublic int cardinality()
BitSet·Î
true·Î
¼³Á¤µÈ ºñÆ®ÀÇ ¼ö¸¦ ¸®ÅÏÇÕ´Ï´Ù.
BitSet·Î
true·Î
¼³Á¤µÈ ºñÆ®ÀÇ ¼öpublic void and(BitSet set)
true·Î
ºñÆ® ¼¼Æ® ÀμöÀÇ ´ëÀÀÇÏ´Â ºñÆ®ÀÇ ÃʱⰪ
µµ trueÀÎ °æ¿ì¿¡ ÇÑÇØ, ÀÌ ºñÆ® ¼¼Æ®°¡ º¯°æµÇ¾î ±× °¢ ºñÆ®ÀÇ °ªÀÌ true°¡ µË´Ï´Ù.
set - ºñÆ® ¼¼Æ®public void or(BitSet set)
true ¿´´ÂÁö, ºñÆ® ¼¼Æ® ÀμöÀÇ ´ëÀÀÇÏ´Â ºñÆ®ÀÇ °ªÀÌ trueÀÎ °æ¿ì¿¡ ÇÑÇØ, ÀÌ ºñÆ® ¼¼Æ®°¡ º¯°æµÇ¾î ±× ºñÆ®ÀÇ °ªÀÌ true°¡ µË´Ï´Ù.
set - ºñÆ® ¼¼Æ®public void xor(BitSet set)
true°¡ µË´Ï´Ù. true·Î
ÀμöÀÇ ´ëÀÀÇÏ´Â ºñÆ®ÀÇ °ªÀÌ false ÀÌ´Ùfalse·Î
ÀμöÀÇ ´ëÀÀÇÏ´Â ºñÆ®ÀÇ °ªÀÌ true ÀÌ´Ù
set - ºñÆ® ¼¼Æ®public void andNot(BitSet set)
BitSet·Î
¼³Á¤µÇ¾î ÀÖ´Â BitSet
ºñÆ®¸¦ ¸ðµÎ Ŭ¸®¾î ÇÕ´Ï´Ù.
set - ÀÌ BitSet¸¦ ¸¶½ºÅ©Çϱâ À§ÇÑ BitSetpublic int hashCode()
BitSet ³»·Î ¼³Á¤µÇ¾î ÀÖ´Â ºñÆ®¿¡
ÇØ¼¸¸ Á¤ÇØÁý´Ï´Ù. ÇØ½Ã Äڵ带 °è»êÇÏ´Â ¾Ë°í¸®ÁòÀº ´ÙÀ½°ú °°ÀÌ ±â¼úÇÒ ¼ö ÀÖ½À´Ï´Ù. ¿¹¸¦ µé¾î, bits ¶ó°í ÇÏ´Â long Çü Á¤¼ö°ª
ÀÇ ¹è¿¿¡
BitSet
ºñÆ®°¡ Æ÷ÇԵȴٰí ÇÕ´Ï´Ù. ±×¸®°í, k°¡ ºÎ°¡ ¾Æ´Ñ °ªÀ¸·Î
((k>>6) < bits.length) && ((bits[k>>6] & (1L << (bit & 0x3F))) ! = 0)±×·¸´Ù°í ÇÏ´Â ½ÄÀÌ ¼º¸³µÇ´Â °æ¿ì¿¡ ÇÑÇØ,
BitSet¿¡ ºñÆ® k°¡ ¼³Á¤µË´Ï´Ù. ÀÌ °æ¿ì
´ÙÀ½°ú °°ÀÌ hashCode ¸Þ¼µå¸¦ Á¤ÀÇÇϸé, ½ÇÁ¦ÀÇ ¾Ë°í¸®ÁòÀÇ ¿Ã¹Ù¸¥ ±¸ÇöÀÌ µË´Ï´Ù.
public int hashCode() {
long h = 1234;
for (int i = bits.length; --i >= 0; ) {
h ^= bits[i] * (i + 1);
}
return (int)((h >> 32) ^ h);
}
ºñÆ®ÀÇ ¼³Á¤ÀÌ ¹Ù²î¸é, ÇØ½Ã Äڵ尪´Â º¯°æµË´Ï´Ù.
ÀÌ ¸Þ¼µå´Â Object
hashCode ¸Þ¼µå¸¦ ¿À¹ö¶óÀ̵å(override) ÇÕ´Ï´Ù.
Object ³»ÀÇ hashCode Object.equals(java.lang.Object),
Hashtable public int size()
BitSet·Î
ºñƮġ¸¦ ³ªÅ¸³»±â À§Çؼ ½ÇÁ¦·Î »ç¿ëÇϰí ÀÖ´Â ºñÆ®ÀÇ ¼ö¸¦ ¸®ÅÏÇÕ´Ï´Ù. ÀÌ ¼¼Æ®·Î ÃÖ´ëÀÇ ¿ä¼Ò´Â ¡¸»çÀÌÁ·Î À̰ÍÀÌ Á¦ÀÏ ¿ä¼ÒÀÔ´Ï´Ù.
public boolean equals(Object obj)
nullÀº ¾Æ´Ï°í, ÀÌ ºñÆ® ¼¼Æ®¿Í ¿ÏÀüÈ÷ °°Àº true
ºñÆ®¼¼Æ®¸¦ °¡Áö´Â Bitset °´Ã¼ÀÎ °æ¿ì¿¡ ÇÑÇØ, °á°ú´Â true ÀÔ´Ï´Ù. Áï, ºÎ°¡ ¾Æ´Ñ int ÇüÀÇ À妽º k¿¡ ´ëÇØ¼
((BitSet) obj). get(k) == this.get(k)ÇÏÁö¸¸ ¼º¸³µÇÁö ¾ÊÀ¸¸é ¾ÈµË´Ï´Ù. 2°³ÀÇ ºñÆ® ¼¼Æ®ÀÇ ÇöÀçÀÇ »çÀÌÁî´Â ºñ±³µÇÁö ¾Ê½À´Ï´Ù.
ÀÌ ¸Þ¼µå´Â Object
equals ¸Þ¼µå¸¦ ¿À¹ö¶óÀ̵å(override) ÇÕ´Ï´Ù.
Object ³»ÀÇ equals obj - ºñ±³ ´ë»óÀÇ °´Ã¼
true, ±×·¸Áö ¾ÊÀº °æ¿ì´Â falsesize() public Object clone()
BitSet¸¦ º¹Á¦ÇÏ´Â °ÍÀ¸·Î µ¿µîÇÑ »õ·Î¿î BitSet¸¦ ÀÛ¼ºÇÕ´Ï´Ù. ÀÌ ºñÆ® ¼¼Æ®ÀÇ º¹Á¦´Â ÀÌ ºñÆ® ¼¼Æ®¿Í ¿ÏÀüÈ÷ °°Àº true
ºñÆ®¸¦ °¡Á®, ÇöÀçÀÇ »çÀÌÁî°¡ °°´Ù ´Ù¸¥ ºñÆ® ¼¼Æ®ÀÔ´Ï´Ù.
ÀÌ ¸Þ¼µå´Â Object
clone ¸Þ¼µå¸¦ ¿À¹ö¶óÀ̵å(override) ÇÕ´Ï´Ù.
Object ³»ÀÇ clone size() public String toString()
BitSet·Î
ºñÆ®°¡ ¼³Á¤ »óÅ·Πº¸°ü À¯ÁöµÇ°í ÀÖ´Â À妽º ¸¶´Ù, ±× À妽ºÀÇ 10 ÁøÇ¥ÇöÀÌ °á°ú¿¡ Æ÷ÇԵ˴ϴÙ. ÀÌ·¯ÇÑ À妽º´Â ÃÖÇÏÁ¤µµ·ÎºÎÅÍ ÃÖ»óÁ¤µµÀÇ ¼ø¼·Î ³ª¶õÇØÁú ¼ö ÀÖ°í, ¡¸, ¡¹(ÄÞ¸¶¿Í ½ºÆäÀ̽º)·Î ´Ü¶ôÁö¾î ¾È¿Ü¸ð·Î µÑ·¯½ÎÀÔ´Ï´Ù. ÀÌ ¶§¹®¿¡
Á¤¼ö ¼¼Æ®ÀÇ º¸Åë
ÀÇ ¼öÄ¡ Ç¥±â°¡ µË´Ï´Ù. Object
toString ¸Þ¼µå¸¦ ¿À¹ö¶óÀ̵å(override) ÇÕ´Ï´Ù.
·Ê:
BitSet drPepper = new BitSet();
drPepper.toString()°¡ ¡¸{}¡¹À» ¸®ÅÏÇÕ´Ï´Ù.
drPepper.set(2);
drPepper.toString()°¡ ¡¸{2}¡¹¸¦ ¸®ÅÏÇÕ´Ï´Ù.
drPepper.set(4); drPepper.set(10);
drPepper.toString()°¡ ¡¸{2, 4, 10}¡¹À» ¸®ÅÏÇÕ´Ï´Ù.
Object ³»ÀÇ toString
|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| ÀÌÀü Ŭ·¡½º ´ÙÀ½ Ŭ·¡½º | ÇÁ·¹ÀÓÀ¸·Î ÇÁ·¹ÀÓ ¾øÀÌ | |||||||||
| °³¿ä: NESTED | Çʵå | constructor | ¸Þ¼µå | »ó¼¼: Çʵå | »ý¼ºÀÚ | ¸Þ¼µå | |||||||||
Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Documentation Redistribution Policy µµ ÂüÁ¶ÇϽʽÿÀ.