FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Unique array of arrays - how can I do this?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Unique array of arrays - how can I do this? [message #181311 is a reply to message #181308] Sat, 04 May 2013 12:20 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
On 04/05/13 12:51, thomas(dot)lehmann(dot)private(at)googlemail(dot)com wrote:
> Hi,
>
> While calculation I get a solution as an array of integers.
> There're many solutions and I would like to keep them in an array.
>
> Because of the algorithm there are different paths to get to
> the same solution but I want to have it once only.
>
> I know that I can use array_unique but that's too slow
> when called too often. I can't wait until end of calculation
> because then I run into memory problems.
>
> So I need an efficient way to add elements once only to
> an array while calculation with an array as element.
>
> How can I do this?
1/ write in in a proper language like C
2/. use a database to store stuff in which has fast algortihms for
dealing with matrix type stuff.

because it sounds like that's what you have - a 2D matrix of integers
you could produce e.g a row hash and index that which would make it fast
to check if you have a POSSIBLE match, and then sort through any
possibles to see if they are exactmatches.

depending on the size though,I'd be tempted to make it a C coded RAM
based thing.
preferably using statically allocated memory if you know a maximum size,
to avoid pointer indirection stuff.

If its huge, I'd use a database and a hash table.


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: replacing spaces with newline
Next Topic: changing video source from youtube to my site
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 05:21:18 GMT 2024

Total time taken to generate the page: 0.06327 seconds