commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Juozas Baliuka" <bali...@centras.lt>
Subject Re: [collections] StaticBucketMap
Date Sat, 22 Jun 2002 16:54:46 GMT
This class has more problems :

1) "put","contais key", ...  are O(n)  in some cases, try something like
this:

 Map map = new StaticBucketMap();
 for( int i = 1; i< 100000; i++  ){
    map.put( new Integer( 255*i ), new Integer(i)  );
}
// All keys are in the same "bucket", it is because  ( h*C ) mod C     =
0
// It is recomended to use something like this :
// final int hash = ( key.hashCode() + PRIME_NUMBER) % m_buckets.length;
// it is good if  "m_buckets.length" is a prime number too.

for( int i = 1; i< 1000000; i++  ){
    map.get( new Integer( 255*i ) );
}


2) It can be used only if number of mappings is constant or "large" (
algorythm O(n), if it is not );
4) Methods "size" is "empty" are allways O(n);
3) Interface implemetation is incorrect ( keySet() .... ).





> Was there a rationale for the name 'Static' in StaticBucketMap. It makes
me
> think it uses a static variable to store the data, which it doesn't. Could
> we consider a different name? Bounded has been suggested elsewhere, does
> this describe it?
>
> Stephen
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:commons-dev-help@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message