X-Git-Url: https://mattmccutchen.net/bigint/bigint.git/blobdiff_plain/b3fe29df9a21e6ade45c470b9b2632e9f75a7aaa..ef2b7c5922c36f93923dd3482c5bfd41b14d82ce:/NumberlikeArray.hh diff --git a/NumberlikeArray.hh b/NumberlikeArray.hh index 79d46df..ab0aae0 100644 --- a/NumberlikeArray.hh +++ b/NumberlikeArray.hh @@ -1,6 +1,5 @@ /* * Matt McCutchen's Big Integer Library -* http://mysite.verizon.net/mccutchen/bigint/ */ /* @@ -20,8 +19,8 @@ #endif /* -* A NumberlikeArray object holds a dynamically -* allocated array of Blocks. It provides certain basic +* A NumberlikeArray object holds a dynamically +* allocated array of Blk. It provides certain basic * memory management features needed by both BigUnsigned * and BigUnsignedInABase, which are both derived from it. * @@ -42,11 +41,13 @@ class NumberlikeArray { public: typedef unsigned int Index; // Type for the index of a block in the array + static const unsigned int N; // The number of bits in a block, defined below. // FIELDS Index cap; // The current allocated capacity of this NumberlikeArray (in blocks) Index len; // The actual length of the value stored in this NumberlikeArray (in blocks) Blk *blk; // Dynamically allocated array of the blocks + /* * Change made on 2005.01.06: * @@ -58,7 +59,7 @@ class NumberlikeArray { * `NULL' as if it were a zero-length array from `new'. * * This is a great convenience because the only code that need be changed - * is the array allocation code. All other code will still work file. + * is the array allocation code. All other code will still work fine. */ // MANAGEMENT @@ -107,11 +108,12 @@ class NumberlikeArray { // Derived classes may wish to override these if differing arrays can // sometimes be considered equivalent. bool operator ==(const NumberlikeArray &x) const; - bool operator !=(const NumberlikeArray &x) const; + bool operator !=(const NumberlikeArray &x) const { return !operator ==(x); } }; /* +* ================================= * BELOW THIS POINT are template definitions; above are declarations. * * Definitions would ordinarily belong in a file NumberlikeArray.cc so that they would @@ -127,6 +129,9 @@ class NumberlikeArray { * so other files including NumberlikeArray will be able to generate real definitions. */ +template +const unsigned int NumberlikeArray::N = 8 * sizeof(Blk); + // MANAGEMENT // This routine is called to ensure the array is at least a