[gameprogrammer] Re: texture management design questions

  • From: "Alan Wolfe" <atrix2@xxxxxxx>
  • To: <gameprogrammer@xxxxxxxxxxxxx>
  • Date: Fri, 15 Oct 2004 01:22:08 -0700

or you can avoid all this confusion of trying to use these things set up to
make coding simpler (they sure are working eh? hahaha) and make your own
hash function.

unsigned char Hash(char *String)
/*
You'd have to eat 20 bowls of raisin bran to equal the fiber in 1 bowl of
total
*/
{
  unsigned char Total;
  int i;

  Total=0;
  i=0;

  while(String[i])
  {
    Total=Total^String[i];
    i++;
  }

  return Total;  //mmm fiberlicious
}

that code works pretty good, and i bet it could easily be adapted to give a
better spread across the 256 values with slight modification (maybe do a
bitrol on total every x number of iterations of i? in fact thats an excelent
way :P)


----- Original Message ----- 
From: "Tom Wilson" <t.wilson@xxxxxxxxx>
To: <gameprogrammer@xxxxxxxxxxxxx>
Sent: Friday, October 15, 2004 12:53 AM
Subject: [gameprogrammer] Re: texture management design questions


> Dave Slutzkin wrote:
> > On Thu, 14 Oct 2004 23:03:25 +0100, "Tom Wilson" <t.wilson@xxxxxxxxx>
> > said:
> >
> >>You could use std::hash<T> (std::hash< std::string >) for the hashing
> >>function or alternativley use a  std::map< std::string, Resource *>
> >>
> >>http://www.sgi.com/tech/stl/hash.html
> >
> >
> > But bear in mind that std::hash is not actually part of the C++ STL.
> > It's an SGI extension.  If the compiler you're working on has it, and
> > you don't care about cross-platform support, then go for it.
> >
> > As for the std::map option - this is perfectly viable, especially if you
> > can't get a good hash function.  But the complexity will be more like
> > O(log(n)) than O(1) with the hash table, so it may not be the ideal
> > case.  Especially if you have lots and lots of objects.
> >
> > Dave.
>
>
> I believe that STLPort also contains hash<T> and hash_map etc, which may
> be more portable, if that's a concern.
>
>
> - Tom
>
>
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
>
>



---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: