Tom
Tom

Reputation: 1301

Are there any well performing methods for representing a NA in a array?

Note I'm specifically referring to the term NA and not NaN because I'm not including only number types

I've been attempting to represent NA values within arrays of different types such as:

int, float, bool, string, class

However I've been having trouble coming up with good methods to represent NA values which don't significantly hurt performance.

For example using a boost::variant named StringNA with the type string and a struct representing a NA struct NA, and then creating an array of type StringNA, is one way of representing a NA value in a array.

But this caused significant performance issues as first I have to check what type the StringNA is holding and second boost::get cast it to get the string.

This is just one idea that I've had. Is there any better methods out there for achieving this?

Just as visualize the problem here is what I'm hoping to achieve:

["String", NA, "String2", "String3", NA]

The amount of NAs in an array are unknown at compile time

Upvotes: 1

Views: 77

Answers (0)

Related Questions