org.hd.d.pg2k.webSvr.exhibit
Class BuiltInFilters.sortRandomN

java.lang.Object
  extended by org.hd.d.pg2k.webSvr.exhibit.BuiltInFilters.sortRandomN
All Implemented Interfaces:
java.io.Serializable, ExprIF, SortIF
Enclosing class:
BuiltInFilters

public static final class BuiltInFilters.sortRandomN
extends java.lang.Object
implements SortIF

Selects N exhibits at random and randomises their order. If the number of exhibits is less than N then this returns all the exhibits.

The first value is the unsigned, positive, base-ten integer value of N.

If the second argument is missing or null then the random number sequence used is taken differently each time we run, else the hash of the second string is taken as the random number seed.

See Also:
Serialized Form

Field Summary
private  int n
          The upper bound on result size.
private  java.lang.String seed
          The seed; if null we use a non-repeatable source.
 
Constructor Summary
BuiltInFilters.sortRandomN(int count, java.lang.String hashSrc)
          More efficient programmatic constructor.
BuiltInFilters.sortRandomN(java.lang.String[] args)
          Takes exactly one or two arguments.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Equality depends on identical seeds and result size.
 int hashCode()
          Hash depends on the seed and the result size limit.
 Name.ExhibitFull[] sort(AllExhibitProperties aep, Name.ExhibitFull[] exhibitNames)
          Sorts the given exhibits (specified by full name) in situ; never null.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

n

private final int n
The upper bound on result size.


seed

private final java.lang.String seed
The seed; if null we use a non-repeatable source.

Constructor Detail

BuiltInFilters.sortRandomN

public BuiltInFilters.sortRandomN(java.lang.String[] args)
Takes exactly one or two arguments. The first argument is the strictly-positive N.

The second argument, if absent or null, indicates that a different random number sequence is used on each run. If present and non-null then its hash is used to seed a random number generator to give repeatable results.


BuiltInFilters.sortRandomN

public BuiltInFilters.sortRandomN(int count,
                                  java.lang.String hashSrc)
More efficient programmatic constructor. Takes count as the first (int) argument and a String to drive the hash or null for a totally random selection.

Method Detail

sort

public Name.ExhibitFull[] sort(AllExhibitProperties aep,
                               Name.ExhibitFull[] exhibitNames)
Description copied from interface: SortIF
Sorts the given exhibits (specified by full name) in situ; never null.

Specified by:
sort in interface SortIF

equals

public boolean equals(java.lang.Object obj)
Equality depends on identical seeds and result size. In other words this checks equivalence rather than the results being identical each time.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Hash depends on the seed and the result size limit.

Overrides:
hashCode in class java.lang.Object

DHD Multimedia Gallery V1.53.0

Copyright (c) 1996-2009, Damon Hart-Davis. All rights reserved.