Questions tagged [lookup]

A lookup (table) is an array that replaces run-time computation with a simpler array indexing operation. The savings in terms of processing time can be significant, since retrieving a value from memory is often faster than undergoing an 'expensive' computation or input/output operation. Over time the definition has become less strict, any kind of searching with a key value can be considered a lookup.

Filter by
Sorted by
Tagged with
1 vote
3 answers
177 views

Any bettter way to achieve this lookup table?

What I need: I need a lookup table. Once the keywords are all found, then the value of the std::unordered_map is returned.And I don't care about the sequence of the ...
user avatar
  • 27
0 votes
1 answer
59 views

importing excel data by matching and performing lookups

This code imports data from a separate sheet and matches it based on Column E's data, it does this for every cell then offsets to the next one (622*6) times. If there are any substitutions for vlookup ...
user avatar
1 vote
0 answers
42 views

Get & change file names from folder

This was originally posted as a Stack Overflow answer. Objective Import all filenames from a folder & change the filename using a mapping table. Challenge As described in the original posting, ...
user avatar
  • 11
10 votes
5 answers
2k views

Sine function calculated via look-up table and linear interpolation

I have been attempting to implement a function calculating values of the sine function. I know that there are several similar threads regarding this topic but my goal was to try to implement such ...
user avatar
  • 375
6 votes
1 answer
219 views

Rust Book: The Twelve Days of Christmas

In order to learn Rust I'm going through The Rust Book and did the implemented a program for the following exercise: Print the lyrics to the Christmas carol “The Twelve Days of Christmas,” taking ...
user avatar
  • 63
3 votes
3 answers
230 views

Word frequencies from large body of scraped text

I have a file with word frequency logs from a very messy corpus of scraped Polish text that I am trying to clean to get accurate word frequencies. Since this is a big text file, I divided it into ...
user avatar
5 votes
2 answers
41k views

Lookup closest value in Pandas DataFrame

I have a DataFrame that contains the data shown below: ...
user avatar
  • 255
4 votes
1 answer
80 views

Naming initialization functions in a lookup table based implementation of integer logarithms

Background (Feel free to skip; the help center just recommended adding background information :) A few days ago, I was looking at some code which happened to use a flat array to store a complete ...
user avatar
4 votes
3 answers
4k views

Lookup table with fixed array

I implemented the following excercise: Implement a lookup table with operations such as find(struct table*, const char*), ...
user avatar
  • 2,986
6 votes
3 answers
3k views

Converting a query result into an key=>value pairs for a lookup table

My app has a number of lookup tables stored in a MySQL database that are used for various purposes such as a select element. Unfortunately, the query results aren'...
user avatar
  • 165
2 votes
1 answer
514 views

Typescript: Recursion file-system lookup

Previously I asked a question to find the best practice of recursively running a function to retrieve all import/export statements of files in NodeJs here. After some discussion I'm not satisfied yet,...
user avatar
  • 151
4 votes
2 answers
72 views

Lookups in list in C

I read about lookups in lists and I think that is what I did. I would like to compare it to a skip list, a binary search or a B+ tree. ...
user avatar
3 votes
0 answers
122 views

FizzBuzz - A quartet of solutions

Since the FizzBuzz challenge is about developing ideas, I've added a third test case for which I chose divisibility by 7 and its accompanying tag "Go". This tag was purposely given a length other ...
user avatar
  • 4,058
2 votes
2 answers
66 views

Comparison of lookup methods

Background (these are the bits technically not for review, but feel free to point out any minor points) An Entity class can be identified by a name and at least ...
user avatar
  • 19.1k
6 votes
2 answers
2k views

Binary search a 2D array for multiple matching criteria fields

Here is what I came up with for a binary search of an array. It allows for searching one or many columns to match. It assumes that array being searched is sorted with the same sort priorities as the ...
user avatar
2 votes
1 answer
79 views

Optimize program to test for divisibility of numbers 3.0

This is a follow up on my previous question. JS1's answer suggested that I should use a precomputed table containing all permutations of the lowest valid number for each number between 1 and MAX. It ...
user avatar
  • 917
4 votes
1 answer
137 views

Look up parameters based on a numpy array of input values

Aim: Write a function that looks up empirical parameters A, B and C for a solar radiation ...
user avatar
  • 143
3 votes
1 answer
2k views

Python lookup table

I'm trying to design a protocol for sending/receiving serial data. The basic plan is to allow for text data to be entered in the command prompt, translate that to a hex string and send it out over ...
user avatar
3 votes
1 answer
26k views

Node.js JSON searching & updating

I'm working on a web-based on/off controller for multiple switches. I'm looking for a good way to manage the current state of a switch and updating the current state on change. So far I've got a <...
user avatar
  • 33
6 votes
2 answers
2k views

How to speed up interval lookup for a piecewise defined function?

At the innermost loop of my software is a lookup of a function value from a piecewise defined function with interpolation between the sample points. Illustration: ...
user avatar
5 votes
2 answers
461 views

Conjugation tables for French

I'm in the process of structuring a model for conjugation tables for French. There are noun inflections, adverb inflections, and 19 verb conjugations. I'm trying to model the data so that every piece ...
user avatar
35 votes
3 answers
16k views

Multiple indexes over an in memory collection for faster search

I have a big in-memory collection of following simplified class: ...
user avatar
11 votes
1 answer
1k views

Partitioned Multikey Map

Below is the code for what I've called a partitioned_multitype_map. This has two major facets: Allowing a lookup based on keys of multiple lengths and of multiple ...
user avatar
  • 11k
5 votes
1 answer
4k views

Project Euler Problem 12 - Highly Divisible Triangular Number - Python Solution Optimization

Project Euler Problem 12 asks (paraphrased): Considering triangular numbers Tn = 1 + 2 + 3 + … + n, what is the first Tn with over 500 divisors? (For example, T7 = 28 has six divisors: 1, 2, 4, 7, ...
user avatar
  • 153
6 votes
1 answer
1k views

Critique of Cardinal Direction Enum

I'm working on a simple game in which I need to track the cardinal direction of an object. I experimented with using the enum's ordinal value, as well as using switches for the rotation, but both ...
user avatar
  • 541
5 votes
1 answer
611 views

Optimize text to ascii lookup map and scalability

Is there a more optimal way of retrieving the character for the letter? I would assume that I would just replace my Entry set loop with another map, but I do not want to bloat the code, because it ...
user avatar
1 vote
1 answer
1k views

Whitelist input data for a lookup by name

I'm whitelisting the input data to an LDAP/AD search on 'sn' (=surname). The purpose is to stop penetration attacks through the app and into the LDAP servers (i.e. no brackets, please). ...
user avatar
  • 198
7 votes
5 answers
819 views

Writing image pixel data to printer code

I've been trying to take image pixel data and write it out into printer code and my results are rather slow. Here is a simplified version of what I have so far (image is a PIL Image object of 1200 x ...
user avatar
  • 339
4 votes
2 answers
235 views

Algorithm (and tests) to parse lists of unsigned 32-bit ints from strings in C

What? I have an algorithm that parses comma separated lists of unsigned 32-bit ints from strings. Here is an example of what a list could look like: ...
user avatar
3 votes
2 answers
706 views

Returning a value based on a lookup

I am trying to return a value (a.tnAddress) from a custom class based on a lookup (foreach loop). Depending on the type of ...
user avatar
5 votes
1 answer
11k views

Multiple criterias in a VLOOKUP in Excel VBA

I have made the following custom defined function in Excel. It works somehow like VLOOKUP(), but it takes two criteria. I think the code is a bit of a mess. Does ...
user avatar
  • 153
8 votes
1 answer
2k views

Python property() implementation that caches getter while still allowing a setter

For a session implementation I needed a property that caches its getter (since it involves a database lookup) but still allows modifications (e.g. assigning a new user and storing that user's id in ...
user avatar
6 votes
1 answer
3k views

Mapping arrays to ranges in Ruby

I have a simple Rails app, which is used to run some clinical surveys. Participants answer sets of questions (multiple-choice, valued 1-5), and, within each set, the answers are summed up and the ...
user avatar
  • 32.9k
11 votes
2 answers
97k views

JSON lookup by key

I always did my lookup in JSON collection like that: ...
user avatar
  • 246
3 votes
1 answer
534 views

JavaScript object to JSON

Since I didn't find a way to properly transform JavaScript object to JSON with PHP, I wrote a snippet. Lets assume the following excerpt from Google Fonts JavaScript API: ...
user avatar
3 votes
1 answer
2k views

Tuple/Lookup conundrum

I have a list of plans and a list of contacts, and I have to check whether contact.ProviderId matches plan.ProviderId. If they ...
user avatar
  • 549
2 votes
1 answer
4k views

Standard library-like linear interpolation table

I'm looking for a general review of a generalized linear interpolation table. Design decisions, anything that's missing, anything that could be clearer or simplified, any style considerations. Keep in ...
user avatar
  • 11k
1 vote
2 answers
484 views

Readability concerns with literal dictionary lookup vs if-else

I'm having concerns about the readability of this piece of code: ...
user avatar
  • 137
3 votes
1 answer
3k views

Dictionary tree optimization

I was wondering if anyone could give me a little bit of help with optimizing a tree-structure in C++. I'm currently developing a dictionary program for a school project but want to take it a bit ...
user avatar
  • 131
3 votes
1 answer
514 views

How can I make my A* algorithm faster?

This is a slightly specialised A* algorithm, basically it allows you to search to and from disabled nodes. It's for a game and we the entities spawn in houses and go into them. The rest of the search ...
user avatar
2 votes
1 answer
120 views

Longest-match lookup via nested dicts

I have the following datastructure to perform a longest-match lookup via nested dicts. For example. cs['a b c d'] with a and <...
user avatar
10 votes
1 answer
3k views

Implementations of prefix lookup tables

I've got a fairly performance sensitive need for fast prefix lookup, and I've built two different implementations trying to optimize for my use case. The first is built off a Trie implementation, and ...
user avatar
  • 365
5 votes
1 answer
386 views

First steps with amd64 assembly

I try to learn amd64 assembler. This is the first thing I tried. This piece of assembly should replicate the functionality of the following piece of C code, which turns a binary sha-256 hash into a ...
user avatar
  • 641
3 votes
1 answer
190 views

Word lookup code optimization

I have a Java class which accepts some data and reads it in as a raster of characters x by y. The class is used then to look for occurrences of a certain word in any direction of the raster and store ...
user avatar
  • 133
23 votes
1 answer
5k views

Create a re-usable class to get different values from enum attribute decorations

I'm wanting to create a Reusable class to work on Enumerations so that I can decorate various Enums with different attributes and I can use this class to get a particular attribute property to display....
user avatar
  • 6,407
2 votes
2 answers
2k views

Alphabetically-sorted word lookup

The goal of this code is to save a list of 250000 words with a number that indicates its frequency. The 250000 are sorted alphabetically but the frequency is unsorted. The idea is that a user must ...
user avatar
7 votes
1 answer
2k views

Optimizing Huffman Decoding

I've been working on implementing a fast Huffman decoder for video decoding. With some help from you, I have been able to produce a decent implementation. However I am still not satisfied with the ...
user avatar
  • 576
3 votes
1 answer
392 views

Method to lookup persistent entities by an example object

i'm currently writing a generic data access object for the persistent entities I have to handle in my JavaEE application. What this codeReview is about is a findByExample method that is used to find ...
user avatar
  • 133
5 votes
1 answer
566 views

Processing XML configuration which stores regular expressions and format strings for a documentation tool

I'm investigating some feature for the ScalaDoc tool, which would allow library writers to link to documentation created by third party tools like JavaDoc. My idea is to have some (XML) configuration ...
user avatar
  • 151
6 votes
1 answer
329 views

Tree/array mashup

I'm currently trying to prove a data structure which I've created to speed up lookups for integral keys. The specific case I have in mind has the following usage case: At start is populated with n ...
user avatar
  • 460