<INTERFACE> The <CD/BitVector/ structure <SEEALSO> <STRREF/BitArray/ <PP> The <STRREF NOLINK/BitVector/ structure provides compacted vectors of booleans, with one bit for each boolean value. A 0 (1) bit corresponds to the boolean value <CD/false/ (<CD/true/), respectively. These vectors can be used to implement sets of integers. Member testing takes constant time. <SPEC> <INCLUDE>MONO_VECTOR <WHERETYPE><ID>elem<TY>bool</WHERETYPE> <SPEC> <VAL>fromString<TY>string -> vector <RAISES> <PROTOTY> fromString <ARG/s/ </PROTOTY> creates a vector from the string argument <ARG/s/, which should contain a hexadecimal representation of the bits set in the vector. Characters 0-9, a-f and A-F are allowed. For example, <VAL>bits<TY>(int * int list) -> vector <RAISES> <PROTOTY> bits (<ARG/sz/, <ARG/l/) </PROTOTY> creates a vector of length <ARG/sz/ with the indices of its set bits given by <ARG/l/. Raises <VAL>getBits<TY>vector -> int list <COMMENT> <PROTOTY> getBits <ARG/vec/ </PROTOTY> returns a list of indices of the bits set in <ARG/vec/, in increasing order. <SPEC> <VAL>toString<TY>vector -> string <COMMENT> <PROTOTY> toString <ARG/vec/ </PROTOTY> encodes a bit vector as a string. The bit vector is zero-padded to the next length that is a multiple of 4. <SPEC> <VAL>isZero<TY>vector -> bool <COMMENT> <PROTOTY> isZero <ARG/vec/ </PROTOTY> returns true if and only if no bits are set. <SPEC> <VAL>extend0<TY>(vector * int) -> vector <RAISES>extend1<TY>(vector * int) -> vector <RAISES> <PROTOTY> extend0 (<ARG/vec/, <ARG/len/) <PROTO> extend1 (<ARG/vec/, <ARG/len/) </PROTOTY> create a new vectors by extending the argument bit vector by 0's or 1's to given length. If <ARG/vec/ is already as long as <ARG/len/, return a copy of the bit vector. Raises <VAL>eqBits<TY>(vector * vector) -> bool <COMMENT> <PROTOTY> eqBits (<ARG/vec/, <ARG/vec2/) </PROTOTY> returns true if the set bits in the two vectors are the same. This is equivalent to: `getBits <ARG/vec/ = getBits <ARG/vec2/ </CODE> <SPEC> <VAL>equal<TY>(vector * vector) -> bool <COMMENT> <PROTOTY> equal (<ARG/vec/, <ARG/vec2/) </PROTOTY> returns true if the two vectors are equivalent, i.e., have the same length and set bits. <SPEC> <VAL>andb<TY>(vector * vector * int) -> vector <VAL>orb<TY>(vector * vector * int) -> vector <VAL>xorb<TY>(vector * vector * int) -> vector <COMMENT> <PROTOTY> andb (<ARG/vec/, <ARG/vec2/, <ARG/len/) <PROTO> orb (<ARG/vec/, <ARG/vec2/, <ARG/len/) <PROTO> xorb (<ARG/vec/, <ARG/vec2/, <ARG/len/) </PROTOTY> creates a new vector of length <ARG/len/ by logically combining the bits of <ARG/vec/ and <ARG/vec2/ using and, or and xor, respectively. If necessary, the vectors are implicitly extended by 0 to be the same length as the new array. <SPEC> <VAL>notb<TY>vector -> vector <COMMENT> <PROTOTY> notb <ARG/vec/ </PROTOTY> creates a new vector with all bits of original vector inverted. <SPEC> <VAL>lshift<TY>(vector * int) -> vector <RAISES> <PROTOTY> lshift (<ARG/vec/, <ARG/i/) </PROTOTY> creates a new vector by inserting <ARG/n/ 0's on the right of <ARG/vec/. The new vector has length <MATH/<ARG/n/ + <MTEXT><VALREF>length</VALREF></MTEXT> <ARG/vec//. Raises <VAL>rshift<TY>(vector * int) -> vector <RAISES> <PROTOTY> rshift (<ARG/vec/, <ARG/i/) </PROTOTY> creates a new vector of length <MATH/max(0,<MTEXT><VALREF>length</VALREF></MTEXT> <ARG/vec/ - <ARG/n/)/ consisting of bits <MATH/n,n+1,...,<MTEXT><VALREF>length</VALREF></MTEXT> <ARG/vec/ - 1/ of <ARG/vec/. If <MATH/<ARG/n/ &GREATEREQ; <MTEXT><VALREF>length</VALREF></MTEXT> <ARG/vec//, the new vector has length 0.` </INTERFACE>