Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 13, 2012, 07:29 PM   #1
farmerdoug
macrumors 6502a
 
Join Date: Sep 2008
A job for pointers?

Have just started to look at this but always well come help.

I need to match a pair of numbers in columns 3 and 4, so that I can get the numbers in cols 1 and 2.

Thanks.
Attached Files
File Type: txt data_sample.txt (2.1 KB, 54 views)

Last edited by farmerdoug; Feb 13, 2012 at 07:39 PM.
farmerdoug is offline   -1 Reply With Quote
Old Feb 13, 2012, 08:30 PM   #2
robvas
macrumors 68000
 
Join Date: Mar 2009
Location: USA
Quote:
Originally Posted by farmerdoug View Post
Have just started to look at this but always well come help.

I need to match a pair of numbers in columns 3 and 4, so that I can get the numbers in cols 1 and 2.

Thanks.
Why do you think you would need pointers?
robvas is offline   0 Reply With Quote
Old Feb 13, 2012, 08:33 PM   #3
farmerdoug
Thread Starter
macrumors 6502a
 
Join Date: Sep 2008
Because I think that the data has to go into a structure more complicated that a simple array. It's just a gut feeling. I don't care if you can do it without pointers.
farmerdoug is offline   0 Reply With Quote
Old Feb 13, 2012, 09:15 PM   #4
mobilehaathi
macrumors 601
 
mobilehaathi's Avatar
 
Join Date: Aug 2008
Location: The Anthropocene
http://en.wikipedia.org/wiki/Associative_array
mobilehaathi is offline   0 Reply With Quote
Old Feb 13, 2012, 09:16 PM   #5
chown33
macrumors 603
 
Join Date: Aug 2009
Combine columns 1 & 2 into a single number. Do the same for columns 3 & 4. Then lookup the number c3:c4 and get the number c1:c2. Then split c1:c2 back into two separate numbers.

For example, if the value in column 2 (call it c2) is in the range [0-9999], then the combined number c1:c2 is simply c1 * 10000 + c2. Assuming both c1 and c2 are non-negative integers.

You get c1 by dividing c1:c2 by 10000 (because integer division truncates). You get c2 from c1:c2 mod 10000.

Same principle applies to numbers in column 3 (c3) and column 4 (c4). Combine, store, lookup, uncombine.

Oh, and make sure you choose a type for the combined numbers that's big enough to hold the full range. Since you haven't specified the range, I'm not going to guess.


A suitable structure for mapping c3:c4 back to c1:c2 depends on how many times you expect to be doing the lookup, how fast it needs to happen, and how many total items there are. A solution could be a simple array, a sparse array, a hashtable, a tree, etc. It could be entirely in RAM, or partly in RAM and partly on disk. It depends entirely on whether you're talking about thousands, millions, or billions of items, and minutes, seconds, or milliseconds of lookup time.
chown33 is offline   0 Reply With Quote
Old Feb 14, 2012, 12:11 AM   #6
Mac_Max
macrumors 6502
 
Join Date: Mar 2004
You could also use an on file SQL database like SQLite. Perhaps a little overkill for this data set but its not a bad skill to practice.
Mac_Max is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Apple job, successful but no job yet. zeroh3ro Community Discussion 6 Mar 22, 2013 12:43 AM
Quick way to get out of my warehouse job and into a computer related job? jc0481 Community Discussion 2 Feb 11, 2013 11:15 AM
Pointers in C... can anyone help me understand? ravenvii Mac Programming 46 Feb 6, 2013 03:10 PM
Two (non-mirror) Screens? Any pointers? ArtOfWarfare iPhone/iPad Programming 3 Nov 12, 2012 01:17 AM
iPad: A few pointers to Ipad 5 being due out soon? gadget123 iPad 18 Oct 31, 2012 01:59 AM

Forum Jump

All times are GMT -5. The time now is 03:52 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC