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.

3
votes
3answers
217 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 ...
0
votes
1answer
4k views

Lookup closest value in Pandas DataFrame

I have a DataFrame that contains the data shown below: ...
4
votes
1answer
60 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 ...
4
votes
3answers
577 views

Lookup table with fixed array

I implemented the following excercise: Implement a lookup table with operations such as find(struct table*, const char*), ...
5
votes
2answers
483 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'...
2
votes
1answer
329 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,...
4
votes
2answers
64 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. ...
3
votes
0answers
82 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 ...
2
votes
2answers
60 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 ...
6
votes
2answers
1k 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 ...
2
votes
1answer
75 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 ...
4
votes
1answer
128 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 ...
3
votes
1answer
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 ...
3
votes
1answer
18k 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 <...
6
votes
2answers
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: ...
5
votes
2answers
430 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 ...
31
votes
3answers
14k views

Multiple indexes over an in memory collection for faster search

I have a big in-memory collection of following simplified class: ...
11
votes
1answer
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 ...
5
votes
1answer
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, ...
6
votes
1answer
791 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 ...
5
votes
1answer
553 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 ...
1
vote
1answer
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). ...
7
votes
5answers
753 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 ...
4
votes
2answers
226 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: ...
3
votes
2answers
686 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 ...
5
votes
1answer
10k 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 ...
8
votes
1answer
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 ...
5
votes
1answer
2k 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 ...
9
votes
2answers
82k views

JSON lookup by key

I always did my lookup in JSON collection like that: ...
3
votes
1answer
444 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: ...
2
votes
1answer
1k 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 ...
2
votes
1answer
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 ...
2
votes
1answer
321 views

Readability concerns with literal dictionary lookup vs if-else

I'm having concerns about readability of this piece of code: messages_dict = {'error':errors, 'warning':warnings}[severity] messages_dict[field_key] = message ...
3
votes
1answer
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 ...
3
votes
1answer
469 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 ...
2
votes
1answer
119 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 <...
10
votes
1answer
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 ...
5
votes
1answer
324 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 ...
3
votes
1answer
184 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 ...
21
votes
1answer
4k 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....
2
votes
2answers
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 ...
6
votes
1answer
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 ...
3
votes
1answer
349 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 ...
5
votes
1answer
559 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 ...
6
votes
1answer
319 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 ...
4
votes
0answers
468 views

Search on a binary tree

From SICP: Exercise 2.66. Implement the lookup procedure for the case where the set of records is structured as a binary tree, ordered by the numerical values of the keys. I wrote the ...
8
votes
1answer
235 views

RubyGem for Enums

A little background first. I've been working on a fairly large Rails application which quickly grew into a breeding ground for "smelly" code. One antipattern we were using a lot was storing objects ...
7
votes
3answers
197 views

Return Data and Update Row without Multiple Lookups?

I have a stored procedure that looks up an article based on the article's title. But I also need to increment a column in the same table that counts the number of times the article has been viewed. ...