Questions tagged [lookup-tables]

A look-up table is an array or matrix of data that contains items that can be searched. Lookup tables may be arranged as key-value pairs, where the keys are the data items being searched (looked up) and the values are either the actual data or pointers to where the data are located.

A look - up table is an array or matrix of data that contains items that are searched. Lookup tables may be arranged as key-value pairs, where the keys are the data items being searched (looked up) and the values are either the actual data or pointers to where the data are located.

706 questions
38
votes
6 answers

Lookup table vs switch in C embedded software

In another thread, I was told that a switch may be better than a lookup table in terms of speed and compactness. So I'd like to understand the differences between this: Lookup table static void func1(){} static void func2(){} typedef enum { …
Plouff
  • 2,881
  • 2
  • 24
  • 43
33
votes
3 answers

Is there a convenient way to apply a lookup table to a large array in numpy?

I’ve got an image read into numpy with quite a few pixels in my resulting array. I calculated a lookup table with 256 values. Now I want to do the following: for i in image.rows: for j in image.cols: mapped_image[i,j] =…
Profpatsch
  • 4,338
  • 5
  • 25
  • 30
26
votes
5 answers

gcc warning: braces around scalar initializer

I have look-up-table as defined below and I'm making use of GCC. When I compile I get warnings as warning: braces around scalar initializer What does this warning mean? How should I initialize this LUT? Am I making a mistake in initializing this…
HaggarTheHorrible
  • 6,335
  • 16
  • 63
  • 79
17
votes
5 answers

TSQL table variable initialization

I have the following TSQL table variable: declare @NumDaysMonth table ( month_id smallint, num_days smallint ) I just want a quick look-up for the number of days in each month. How can I initialize this table like a C array: int…
CodeKingPlusPlus
  • 12,865
  • 46
  • 123
  • 204
16
votes
6 answers

Java 8 - store lambdas in List

I wonder if it's possible to store lambdas in some container, for ex. ArrayList or HashMap. I want to change that code: public enum OPCODE implements BinaryOperator { MOV((x, y) -> y), INC((x, y) -> ++x), DEC((x, y) -> --x), …
Jump3r
  • 952
  • 10
  • 28
16
votes
4 answers

Country, State, Province WebService?

Are there any good webservices out there that provide good lookup information for Countries and States/Provinces? If so what ones do you use?
Smallinov
  • 1,276
  • 2
  • 9
  • 16
15
votes
4 answers

Is there a simple way to create a javascript lookup table?

I'm looking for a simple way of looking up a value, using javascript, against a number of dimensions: eg. (I'm going to use products and product options to describe this, the data is coming from a database in a very similar format) Colour Size…
Paul
  • 8,821
  • 11
  • 56
  • 103
15
votes
8 answers

Fastest possible string key lookup for known set of keys

Consider a lookup function with the following signature, which needs to return an integer for a given string key: int GetValue(string key) { ... } Consider furthermore that the key-value mappings, numbering N, are known in advance when the source…
Pavel Minaev
  • 94,882
  • 25
  • 209
  • 280
14
votes
2 answers

Calculate a 32-bit CRC lookup table in C/C++

I want to calculate a 32-bit CRC lookup table. One way I tried is by using the following code from this website: #include #include void make_crc_table() { unsigned long POLYNOMIAL = 0x04c11db7; unsigned long WIDTH = 8…
Programmer_D
  • 561
  • 2
  • 11
  • 25
13
votes
2 answers

What's the best way to do a lookup table in C?

I am working on an embedded C project. I have an LCD display and for each character there is a 5x7 dot matrix. To display a specific character you have to shift in 5 bytes that correlate with the dots to turn on. So I need to make some kind of…
PICyourBrain
  • 9,386
  • 26
  • 87
  • 133
13
votes
5 answers

Simple lookup to insert values in an R data frame

This is a seemingly simple R question, but I don't see an exact answer here. I have a data frame (alldata) that looks like this: Case zip market 1 44485 NA 2 44488 NA 3 43210 NA There are over 3.5 million…
Dino Fire
  • 399
  • 2
  • 5
  • 9
13
votes
3 answers

Small Tables in Python?

Let's say I don't have more than one or two dozen objects with different properties, such as the following: UID, Name, Value, Color, Type, Location I want to be able to call up all objects with Location = "Boston", or Type = "Primary". Classic…
akoumjian
  • 1,246
  • 1
  • 13
  • 19
11
votes
3 answers

Replacing functions with Table Lookups

I've been watching this MSDN video with Brian Beckman and I'd like to better understand something he says: Every imperitive programmer goes through this phase of learning that functions can be replaced with table lookups Now, I'm a C# programmer…
Jamie Dixon
  • 49,653
  • 18
  • 119
  • 157
11
votes
4 answers

Should lookup values be modeled as aggregate roots?

As part of my domain model, lets say I have a WorkItem object. The WorkItem object has several relationships to lookup values such as: WorkItemType: UserStory Bug Enhancement Priority: High Medium Low And there could possibly be more, such as…
Landon Poch
  • 832
  • 1
  • 8
  • 17
10
votes
2 answers

C# is half as slow than Java in memory access with loops?

I have two pieces of code that are identical in C# and Java. But the Java one goes twice as fast. I want to know why. Both work with the same principal of using a big lookup table for performance. Why is the Java going 50% faster than C#? Java…
michael
  • 105
  • 5
1
2 3
47 48