July 28, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Visual C++ 2008 Feature Pack: MFC Enhancements

  • May 12, 2008
  • By Nick Wienholt
  • Send Email »
  • More Articles »

Other Additions

The TR1 updates also include a comprehensive random number generation library. There are a number of random number generations schemes included in TR1, including bernoulli_distribution, binomial_distribution, exponential_distribution, gamma_distribution, geometric_distribution, normal_distribution, and poisson_distribution. The distribution classes are used by random number generation algorithms, such as linear_congruential and mersenne_twister, which are included as part of the TR1 library. The following code snippet shows random number generation with the mersenne_twister algorithm and gamma_distribution.

using namespace std::tr1;
...
//use TR1 typedef mt19937 for Mersenne twister algorithm
mt19937 randomAlg;
gamma_distribution <double> randomDist;
double d = randomDist(randomAlg);

Joining the new array collection in TR1 are the new collections unordered_set, unordered_map, and unordered_multimap. As the type name suggests, these new collections differ from the existing STL set and map collections by not ordering the sequence that they maintain. The advantage of avoiding ordering is that the cost of element insertion, deletion, and location is an O(1) operation (in other words, the computational cost is independent of the collection size). The main disadvantage of the lack of ordering is that collection equality is harder to determine, because a collection containing the same elements could have them located in different positions.

Conclusion

The TR1 updates are an exciting step towards C++0x, and represent a significant evolution in Standard C++ that ensures that the C++ language remains strong, relevant, and modern for the foreseeable future. TR1 brings many of the benefits and features to C++ that programmers in managed languages have come to expect, and still maintains the massive investment that the software industry has in C++ code.

The release of the TR1 updates in the Visual C++ 2008 Feature Pack demonstrates Microsoft's continued support of and investment in the Visual C++ product, and shows that native code developers still have many good years ahead of them at the keyboard.

About the Author

Nick Wienholt is an independent Windows and .NET consultant based in Sydney. He is the author of Maximizing .NET Performance and co-author of A Programmers Introduction to C# 2.0 from Apress, and specialises in system-level software architecture and development, with a particular focus of performance, security, interoperability, and debugging.

Nick is a keen and active participant in the .NET community. He is the co-founder of the Sydney Deep .NET User group and writes technical articles for Australian Developer Journal, ZDNet, Pinnacle Publishing, CodeGuru, MSDN Magazine (Australia and New Zealand Edition) and the Microsoft Developer Network. An archive of Nick's SDNUG presentations, articles, and .NET blog is available at www.dotnetperformance.com.

In recognition of his work in the .NET area, he was awarded the Microsoft Most Valued Professional Award from 2002 through 2007.





Page 2 of 2



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel