On 10/16/2013 04:09 AM, Maciej Sumiński wrote:
> Hi all,
> 
> We need a ratsnest that works with the GAL, therefore I present to you 
> the blueprints for that part:
> https://blueprints.launchpad.net/kicad/+spec/ratsnest-gal
> 
> I have seen many great ideas appearing on the mailing list, that's why 
> everyone is welcome to share thoughts. I believe it may lead to a 
> better/faster/more functional implementation in the end.
> Regards,
> Orson
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
> .
> 


> It requires hashing function to be prepared (eg. using boost::hash), possibly 
> not very >
demanding on CPU cycles.


Sounds good.  A hashtable is probably the best bet.  Suggest adding it to 
hashtables.h
which is where we've put all the hashtables.

Might this work?

/// hash function for RATS_ELEM type
/// taken from: 
http://www.boost.org/doc/libs/1_53_0/libs/unordered/examples/fnv1.hpp
struct rats_hash
{
    std::size_t operator()( const RATS_ELEM& e ) const
    {
        std::size_t hash = 2166136261u;

        hash ^= e.m_x;
        hash *= 16777619;
        hash ^= e.m_y;
        hash *= 16777619;       
        hash ^= e.m_layer;
        hash *= 16777619;       
        hash ^= e.m_net;

        return hash;
    }
};


It puts in the members in reverse order of importance, m_net being most 
important.
I got this from my "const char*" hash function for which there is a URL 
reference in
hashtables.h



_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to