Annotation of researchv10dc/man/man3/bits.3, revision 1.1

1.1     ! root        1: .TH BITS 3+
        !             2: .CT 2 datatype
        !             3: .SH NAME
        !             4: bits \- variable length bit strings
        !             5: .SH SYNOPSIS
        !             6: .nf
        !             7: .B "#include <Bits.h>"
        !             8: .PP
        !             9: .B "typedef unsigned long Bits_chunk;"
        !            10: .PP
        !            11: .B "struct Bits {"
        !            12: .B "   Bits() { }"
        !            13: .B "   Bits(Bits_chunk, unsigned = 1);"
        !            14: .B "   Bits(const Bits&)"
        !            15: .B "   ~Bits();
        !            16: .BR "  Bits& operator= (const Bits&);  // " also " = &= |= ^=
        !            17: .BR "  Bits& operator<<= (int);                // " also " >>=
        !            18: .B "   int operator[] (unsigned);"
        !            19: .B "   operator Bits_chunk();"
        !            20: .B "   unsigned size();"
        !            21: .B "   unsigned size(unsigned);"
        !            22: .B "   Bits& compl();"
        !            23: .B "   Bits& concat(const Bits&);"
        !            24: .B "   Bits& set(unsigned, unsigned long = 1);"
        !            25: .B "   Bits& reset(unsigned);"
        !            26: .B "   Bits& compl(unsigned);"
        !            27: .B "   unsigned count();"
        !            28: .B "   unsigned signif();"
        !            29: .B "   unsigned trim();"
        !            30: .B "};"
        !            31: .PP
        !            32: .B "Bits operator~ (const Bits&);
        !            33: .BR "Bits operator& (const Bits&, const Bits&); // " also " | ^
        !            34: .BR "Bits operator<< (const Bits&, int);                // " also " >>
        !            35: .BR "int operator< (const Bits&, const Bits&);  // " also " > <= >= == !=
        !            36: .fi
        !            37: .SH DESCRIPTION
        !            38: A
        !            39: .B Bits
        !            40: object contains a variable-length bit string.
        !            41: The bits of a
        !            42: .B Bits
        !            43: object
        !            44: .I b
        !            45: are numbered from 0 through
        !            46: .IB b .size()\fR\-1,\fP
        !            47: with the rightmost bit numbered 0.
        !            48: .PP
        !            49: .B Bits_chunk
        !            50: is the largest unsigned integral type
        !            51: acceptable for conversion to and from
        !            52: .BR Bits ,
        !            53: .BR "unsigned long" 
        !            54: in this implementation.
        !            55: .SS Constructors
        !            56: .TP \w'\fIa\fL.concat(\fIb\fL)\ 'u
        !            57: .B Bits()
        !            58: An empty bit string.
        !            59: .TP
        !            60: .BI Bits( n )
        !            61: The bits are copied from the binary representation of
        !            62: .I n
        !            63: with the ones-digit of
        !            64: .I n
        !            65: becoming bit 0.
        !            66: Leading zero-bits are removed,
        !            67: except that
        !            68: .B Bits(0)
        !            69: is a one-bit string.
        !            70: .TP
        !            71: .BI Bits( n , m )
        !            72: The same, but padded with leading zeros to size
        !            73: .I m
        !            74: if necessary.
        !            75: .SS Operators
        !            76: Bit strings have
        !            77: value semantics;
        !            78: assigning a
        !            79: .B Bits
        !            80: object or passing it to or returning it from a function
        !            81: creates a copy of its value.
        !            82: The meanings of operators are mostly predictable from C.
        !            83: .PP
        !            84: Under binary and comparison operators,
        !            85: the shorter operand
        !            86: is considered to be padded on the left with zeros to the
        !            87: length of the longer.
        !            88: If, after padding, two strings of different length compare equal,
        !            89: the shorter is deemed the smaller.
        !            90: .PP
        !            91: Negative shift amounts
        !            92: reverse the sense of shift operators.
        !            93: .PP
        !            94: Under conversion (or assignment) to a
        !            95: .BR Bits_chunk ,
        !            96: a
        !            97: .B Bits
        !            98: is interpreted as an unsigned integer.
        !            99: If it has a value small enough to fit,
        !           100: that value is assigned.
        !           101: Otherwise, a non-zero value is
        !           102: assigned.
        !           103: Thus a
        !           104: .B Bits
        !           105: is considered `true' in an
        !           106: .B if
        !           107: test if it contains any one-bit, `false' otherwise.
        !           108: .TP \w'\fIa\fL.concat(\fIb\fL)\ 'u
        !           109: .IB a [ s ]
        !           110: Bit number
        !           111: .I s
        !           112: of
        !           113: .IR a ;
        !           114: 0 if
        !           115: .I s
        !           116: is out of bounds.
        !           117: .SS Other functions
        !           118: .TP \w'\fIa\fL.concat(\fIb\fL)\ 'u
        !           119: .IB a .size( s )
        !           120: Set the size of
        !           121: .I a
        !           122: to
        !           123: .I s
        !           124: by truncating or padding with zeros on the left as necessary.
        !           125: Return the new size.
        !           126: .TP
        !           127: .IB a .compl()
        !           128: Complement the bits of
        !           129: .I a.
        !           130: Return
        !           131: .I a.
        !           132: .TP
        !           133: .IB a .set( s )
        !           134: .PD 0
        !           135: .TP
        !           136: .IB a .reset( s )
        !           137: .TP
        !           138: .IB a .compl ( s )
        !           139: Set, reset, or complement bit
        !           140: .I s
        !           141: of
        !           142: .I a.
        !           143: No effect if
        !           144: .IB a .size()<= s.
        !           145: Return
        !           146: .I a.
        !           147: .PD
        !           148: .TP
        !           149: .IB a .set( s , n )
        !           150: If
        !           151: .I n
        !           152: is 0, reset bit
        !           153: .I s
        !           154: of
        !           155: .I a,
        !           156: otherwise set bit
        !           157: .I s.
        !           158: Equivalent to
        !           159: .BR "n? a.set(s): a.reset(s)" .
        !           160: .TP
        !           161: .IB a .count()
        !           162: Return the number of one-bits in
        !           163: .I a.
        !           164: .TP
        !           165: .IB a .signif()
        !           166: Return the number of significant bits in
        !           167: .BR a :
        !           168: one more than the
        !           169: number of the leftmost one-bit, or
        !           170: zero if there is no one-bit.
        !           171: .TP
        !           172: .IB a .trim()
        !           173: Discard high-order zero-bits.
        !           174: Equivalent to
        !           175: .BR a.size(a.signif()) .
        !           176: .TP
        !           177: .IB a .concat( b )
        !           178: Concatenate the value of
        !           179: .I b
        !           180: to the right (low-order) end of
        !           181: .I a.
        !           182: Return
        !           183: .I a.
        !           184: .TP
        !           185: .BI concat( a , b )
        !           186: Return a newly created concatenated object.
        !           187: .SH DIAGNOSTICS
        !           188: An operation that runs out of memory sets
        !           189: the length of the affected
        !           190: .B Bits
        !           191: to zero.
        !           192: .SH BUGS
        !           193: Too bad C++ can't support
        !           194: .BR "a[s] = n" .
        !           195: .br
        !           196: Things would be more consistent if
        !           197: .B Bits(0).size()
        !           198: were zero.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.