An algorithm question
-
I have an application ,need to read hardware IO, each IO data be coded to an unsigned integer, 4 digits - 7 digits. Quantity of all possible integers is 240, every integer is unique for example:
1000,1002, 120008, 1318001,14702 , 4003...
After coding step, the coded integers need to be send out in a sequence.
12002 <- 4001 <- 10089 <- 5007 <- ...
Quantity of integers are limited to 128, but, the quantity number is not fixed. Perhaps send-cycle1 is 4 integers, send-cycle2 is 120 integers, send-cycle3 is 2 integers, send-cycle4 is 0 integer. ... And during cycle period, maybe there are duplicated data be read,but, sending sequence should not take duplicated data. Logic is :
read data -> already in sequence, discard/ new data -> sequence
I wonder what data structure is good for the above logic and application.
-
I have an application ,need to read hardware IO, each IO data be coded to an unsigned integer, 4 digits - 7 digits. Quantity of all possible integers is 240, every integer is unique for example:
1000,1002, 120008, 1318001,14702 , 4003...
After coding step, the coded integers need to be send out in a sequence.
12002 <- 4001 <- 10089 <- 5007 <- ...
Quantity of integers are limited to 128, but, the quantity number is not fixed. Perhaps send-cycle1 is 4 integers, send-cycle2 is 120 integers, send-cycle3 is 2 integers, send-cycle4 is 0 integer. ... And during cycle period, maybe there are duplicated data be read,but, sending sequence should not take duplicated data. Logic is :
read data -> already in sequence, discard/ new data -> sequence
I wonder what data structure is good for the above logic and application.
-
I have an application ,need to read hardware IO, each IO data be coded to an unsigned integer, 4 digits - 7 digits. Quantity of all possible integers is 240, every integer is unique for example:
1000,1002, 120008, 1318001,14702 , 4003...
After coding step, the coded integers need to be send out in a sequence.
12002 <- 4001 <- 10089 <- 5007 <- ...
Quantity of integers are limited to 128, but, the quantity number is not fixed. Perhaps send-cycle1 is 4 integers, send-cycle2 is 120 integers, send-cycle3 is 2 integers, send-cycle4 is 0 integer. ... And during cycle period, maybe there are duplicated data be read,but, sending sequence should not take duplicated data. Logic is :
read data -> already in sequence, discard/ new data -> sequence
I wonder what data structure is good for the above logic and application.
-
In order to get better help you should detail your scenario. For instance, I have no idea of what you mean with
Quote:
After coding step, the coded integers need to be send out in a sequence. 12002 <- 4001 <- 10089 <- 5007 <- ...
Veni, vidi, vici.
-
I have an application ,need to read hardware IO, each IO data be coded to an unsigned integer, 4 digits - 7 digits. Quantity of all possible integers is 240, every integer is unique for example:
1000,1002, 120008, 1318001,14702 , 4003...
After coding step, the coded integers need to be send out in a sequence.
12002 <- 4001 <- 10089 <- 5007 <- ...
Quantity of integers are limited to 128, but, the quantity number is not fixed. Perhaps send-cycle1 is 4 integers, send-cycle2 is 120 integers, send-cycle3 is 2 integers, send-cycle4 is 0 integer. ... And during cycle period, maybe there are duplicated data be read,but, sending sequence should not take duplicated data. Logic is :
read data -> already in sequence, discard/ new data -> sequence
I wonder what data structure is good for the above logic and application.
econy wrote:
I wonder what data structure is good for the above logic and application.
The problem in this question is that you didn't actually tell us a lot about the logic and application. You only told us about the scope of input values, and that these values are gathered in batches and processed (filtering out duplicates) before sending out. You didn't tell us if anything of this is time-critical, or you're working with restricted amounts of memory - should we try to optimize for either? Also, is it more important for the receiver to receive the data in a timely manner, requiring on-the-fly processing so you can send out the batch right after the end of the cycle - or can you afford to delay the processing until after receiving the last input of the cycle, before sending it out? The answer to these questions will influence what algorithm to use, and the algorithm will influence what data structures to use.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto) Point in case: http://www.infoq.com/news/2014/02/apple_gotofail_lessons[^]