lookup

Data lookup method for small data set with Java?

 ̄綄美尐妖づ 提交于 2019-12-10 19:19:06
问题 We have to lookup some data based on three input data fields. The lookup has to be fast. There are only about 20 possible lookup combinations. We've implemented this using a static HashMap instance where we create a key by concatinating the three data fields. Is there a better way to do this or is this the way to go? Code is below. Update : I'm not implying that this code is slow. Just curious if there is a better way to do this. I thought there might be a more elegant solution but I'm happy

Fastest possible lookup for known static set of integers?

纵饮孤独 提交于 2019-12-10 19:04:37
问题 I am implementing a VM compiler, and naturally, I've come to the point of implementing switches. Also naturally, for short switches, a sequential lookup array would be optimal but what about bigger switches? So far I've come up with a data structure that gives me a pretty good lookup time. I don't know the name of that structure, but it is similar to a binary tree but monolith, with the difference it only applies to a static set of integers, cannot add or remove. It looks like a table, where

More efficient way to look up dictionary values whose keys start with same prefix

好久不见. 提交于 2019-12-10 13:07:54
问题 I have a dictionary whose keys come in sets that share the same prefix, like this: d = { "key1":"valA", "key123":"valB", "key1XY":"valC", "key2":"valD", "key2-22":"valE" } Given a query string, I need to look up all the values associated with keys that start with that prefix, e.g. for query="key1" I need to get ["valA", "valB", "valC"] My implementation below works but is too slow for a large number of queries since the dictionary d has about 30,000 keys and most of the keys are more than 20

How to check if an element exists in a Python array (Equivalent of PHP in_array)?

我只是一个虾纸丫 提交于 2019-12-10 12:44:29
问题 I'm new to Python and I'm looking for a standard function that would tell me if an element is present in an array. I found the index method but it throws an exception if the element is not found. I just need some simple function that would return true if the element is in the array or false if not. Basically an equivalent to PHP in_array . 回答1: >>> 1 in [0, 1, 2, 3, 4, 5] True 来源: https://stackoverflow.com/questions/14743156/how-to-check-if-an-element-exists-in-a-python-array-equivalent-of

How can I create objects with reference using instantobjects framework programmaticaly in Delphi code

…衆ロ難τιáo~ 提交于 2019-12-10 12:15:30
问题 I am a experimenting with instantobjects. I have two simple classes tband and tcountry both are defined as stored. tband has a properts named tcountry referencing the tcountry class/table. (country is the lookup table). When creating a new band I want the user to be able to select the country in the form from a list/combo and then save the band object. I tried something like: Band.Create(nil); Country.Create(nil); Country := CountrySelector.CurrentObject as TCountry; // here I get an

Look up, match, then multiply across tabs and replace active cell

岁酱吖の 提交于 2019-12-10 11:57:46
问题 okay i just started using VBA/macros today and im pretty pleased with my progress so far :) but hit a brick wall i think above my pay grade... not looking for a bailout i'd like to understand this for the future. My job could really use these.... Data tab called "Quotation Tool": UPDATED CURRN TAB Then I have a currency conv tab called "Currencies" (refreshed web data): What I want to do: search the column for currency on data tab, find "CNY" or "HKD" or another currency. when it finds it i

R conditional replace more columns by lookup

≡放荡痞女 提交于 2019-12-10 11:14:07
问题 Lets say we do have lots of data columns (with names mycols and also some unnamed ones that should not be processed in this case) in dataframe df1 and a column subj which is also an index to another dataframe df2 with columns repl and subj (in this second dataframe is subj unique) and much other nonimportant columns (their only role in this is, that we cannot suppose that there are just 2 columns). I would like to replace a subset of columns ( df1[,mycols] ) in such a way, that if there is an

Lookup function in SSRS report

会有一股神秘感。 提交于 2019-12-10 10:08:50
问题 I have one dataset Dataset1 and in that I am displaying data based on grouping. The data is like this CityColumn CountColumn City1 5 City2 3 The query of above datase is like this : select count(*) as "CountColumn" from City group by CityColumn Here in above dataset I have counted using grouping on CityColumn . Now I have created another Dataset Dataset2 and in that The data is like this CityColumn City1 City2 City3 Now in dataset2 I have add one calculated field called TotalCount and used

Data structure with two way O(1) lookup. Hashtable?

喜欢而已 提交于 2019-12-09 17:48:21
问题 I'm implementing a system where I have a list of names and each person has 1 phone number. I need to be able to take a name and look up the phone number, or take a phone number and look up a name. I know I could do this by having two hashtables - one which goes from names to phone numbers and one which goes from phone numbers to names. Then I can look up in either direction in O(1) time. However this seems like I am storing too much data - every name and every phone number is stored twice. Is

Finding minimum value in index(match) array [EXCEL]

拟墨画扇 提交于 2019-12-08 22:10:27
问题 This is my simple table A B C tasmania hobart 21 queensland brisbane 22 new south wales sydney 23 northern territory darwin 24 south australia adelaide 25 western australia perth 26 tasmania hobart 17 queensland brisbane 18 new south wales sydney 19 northern territory darwin 11 south australia adelaide 12 western australia perth 13 index match array formula: =INDEX(A2:C9,MATCH(1,(H4=$A:$A)*(I4=$B:$B),0),3) Basically A and B are my lookup criteria while C is the value I want to get. I want C