/* * HT Editor * tools.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "tools.h" #include "data.h" #include "htdebug.h" #include #include #include #include uint32 delinearize(uint32 d) { return d*0x8088405+1; /* there's magic in here... */ } uint64 delinearize64(uint64 d) { return (uint64(delinearize(d))<<32)| delinearize(d>>32); /* there's less magic in here... */ } int compare_keys_uint_delinear(Object *key_a, Object *key_b) { uint a = delinearize(((UInt*)key_a)->value); uint b = delinearize(((UInt*)key_b)->value); if (a>b) return 1; else if (a