devxlogo

Tip Bank

A Standard Bit Vector

The Standard Template Library provides the specialization vector. The specialization is implemented in a way that squeezes each element into a single bit, rather than a bool variable. When a

Replacement for Now() and Timer()

The simple BetterNow() function, shown here, replaces the built-in Now() function. It’s faster (10 microseconds vs. 180 microseconds on a Pentium 166MMX) and more accurate, potentially supplying one-millisecond resolution, instead

Subclassing Anonymously

Anonymous classes in Java are defined inside another class (i.e., they are inner classes), do not have a name, and are defined inside a Java expression such as an assignment

Tile an Image Onto a Form

Adding this code to a form causes it to tile the image stored in Picture1 across the entire form whenever the form requires a refresh: Private Sub Form_Load() With Picture1

Adding Full Paths to a TreeView

Have you ever wanted to add nodes to a TreeView control using a full path instead of adding a node at a time? You can do it with this code:

Checking a Vector’s Capacity

The member function capacity() returns the total number of elements that a vector can hold without requiring reallocation: #include #include using namespace std;void main() { vector vi; vi.reserve(10); //make room

Detecting Alphanumeric Characters in a String

Java provides a convenient function for detecting whether a character is alphanumeric (1-26 and 0-9) or not. This function is available in the class Character. Some of the other related