performance

Fast incremental sort -- Lars Hagen

Lars Hagen describes in his blog post a strategy to solve the problem of a fast incremental sort.

Fast incremental sort

by Lars Hagen

From the article

I recently came across the need for an incremental sorting algorithm, and started to wonder how to do it optimally.

The incremental sorting problem is described here, and is an “online” version of partial sort. That is, if you have already sorted kk elements, you should be able to quickly sort k+1k+1 elements, and so on.

Incremental sorts can be useful for a number of cases:

  • You want sorted items, but you don’t know how many elements you’ll need. This could often happen when you are filtering the resulting sequence, and you don’t know how many items will be filtered out.
  • You are streaming the sequence, so even though you want the whole sequence, you want the first elements as quickly as possible.

We’ll see how branch misprediction and other constant factors can make the naive asymptotically optimal version far slower than a practical implementation.

RAII without exceptions--Eli Bendersky

Is RAII in C++ only possible with exceptions? Eli Bendersky clarifies the matter:

C++: RAII without exceptions

by Eli Bendersky

From the article:

this post is not about whether exceptions are good or bad. What it is about is RAII as a C++ dynamic resource management technique that stands on its own and is useful with or without exceptions. In particular, I want to explain why RAII is indeed useful even if you have exceptions disabled in your C++ code...

Searching and replacing in strings with boost

My series on building applications with Qt an boost continues:

Searching and replacing in strings with boost

by Jens Weller

From the article:

The next big milestone for my CMS is to actually generate HTML files, and I'm almost there. I'll reach it in the next two weeks, most code is written, just a little bit of refactoring is needed. This blog post is about searching and replacing in strings. As I started last week with implementing the functionality, that turns the data in my CMS into an HTML website.

There needs to be a lot of text transformed, in order to turn a shared structure like a cross page layout into a single, special HTML file, one of those transformations is, to replace the internal links with the correct links. A link to a different page in the same website cannot be represented as a text link, instead it is represented by a linkid, which corresponds to the Page it points to. This is to have still the correct link, if the page is renamed or moved...

Using parallelism with boost::future

A new blog entry about parallelism and boost::future:

Using parallelism with boost::future

by Jens Weller

From the article:

... While I'm fine with that the application locks up kind of hard during writing a GB zip file (its only job), I'd like to be as fast as possible. Thats why I decided to parallelize the part of the application that reads the file paths via boost::filesystem...