# PSF-LoginServer - master - net.psforever.objects.guid.selector.RandomSelector
PSF - LoginServer - master - net.psforever.objects.guid.selector.RandomSelector
Keywords: PSF LoginServer master net.psforever.objects.guid.selector.RandomSelector

PSF-LoginServer - master < Back


# Packages

-  package root
  Definition Classes
    root
-  package net
  Definition Classes
    root
-  package psforever
  Definition Classes
    net
-  package objects
  Definition Classes
    psforever
-  package guid
  Definition Classes
    objects
-  package selector
  Definition Classes
    guid
- NumberSelector
- OpportunisticSelector
- RandomSelector
- RandomSequenceSelector
- SpecificSelector
- StrictInOrderSelector

c

net.psforever.objects.guid.selector

# RandomSelector

###

#### class RandomSelector extends NumberSelector

Get a pseudorandom number from a pool of numbers. The contained logic is similar to `RandomSequenceSelector`. It is not reliant of a shrinking pool that composes into some sequence of all the numbers, however; the numbers are re-introduced to the selection as long as the pool is used. This allows for the sequence to contain repeat numbers far before ever visiting all of the numbers once.
During the selection process:
The index is the position from where the selection begins, and the end of the `Array` is where the selection ends. Once a position between those two indices is selected, that number is extracted. The number at the start position is swapped into the position where the selection number was extracted. The start position is then set to an invalid number, and the start index is advanced. Repeat next request.
During the return process:
The returned number is added to the input `Array` at the position just before the current selection position. The selection index is then reversedback to re-include the returned number. The normal return index is not used in this algorithm.

Source
  RandomSelector.scala
See also

  `RandomSequenceSelector`

Linear Supertypes
NumberSelector, AnyRef, Any

Ordering

1. Alphabetic
2. By Inheritance

Inherited

1. RandomSelector
2. NumberSelector
3. AnyRef
4. Any

1. Hide All
2. Show All

Visibility

1. Public
2. Protected

### Instance Constructors

1.  new RandomSelector()

### Value Members

1.  final def !=(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
2.  final def ##: Int
   Definition Classes
     AnyRef → Any
3.  final def ==(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
4.  def Format(ary: Array[Int]): Unit

   Accept the indexing pool from which numbers are selected and returned.

   Accept the indexing pool from which numbers are selected and returned. Correct its format to suit the current `NumberSelector` algorithms.
   Moving all of the invalid negative-ones (-1) to the left of the current valid indices works for most selectors. The `selectionIndex` is set to the first valid number available from the left. The `ret` index is set to index zero.

   ary

     the `Array` of `Int` numbers

   Definition Classes
     NumberSelector
5.  def Get(ary: Array[Int]): Int

   Accept a provided `pool` and select the next number.
   ...

   Accept a provided `pool` and select the next number.
   ...

   ary

     the `Array` of `Int` numbers from which to draw a new number

   returns

     an `Int` number

   Definition Classes
     RandomSelector → NumberSelector
6.  def Return(number: Int, ary: Array[Int]): Boolean

   Give a number back to a specific collection following the principles of this selector.
   The number is always returned to a "used" index position near the front of the array.

   Give a number back to a specific collection following the principles of this selector.
   The number is always returned to a "used" index position near the front of the array. It locates this position by incrementally traversing the `Array` behind the position used in `Get`. Asides from selection, a disorderly reinsertion of numbers back into the pool is also a source of randomness.

   number

     the number to be returned

   ary

     the `Array` of `Int` numbers to which the number is to be returned

   returns

     `true`, if this return was successful; `false`, otherwise

   Definition Classes
     RandomSelector → NumberSelector
7.  def ReturnIndex: Int
   Definition Classes
     NumberSelector
8.  def SelectionIndex: Int
   Definition Classes
     NumberSelector
9.  final def asInstanceOf[T0]: T0
   Definition Classes
     Any
10.  def clone(): AnyRef
    Attributes
      protected[lang]
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.CloneNotSupportedException]) @native()
11.  final def eq(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
12.  def equals(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef → Any
13.  def finalize(): Unit
    Attributes
      protected[lang]
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.Throwable])
14.  final def getClass(): Class[_ <: AnyRef]
    Definition Classes
      AnyRef → Any
    Annotations
      @native()
15.  def hashCode(): Int
    Definition Classes
      AnyRef → Any
    Annotations
      @native()
16.  final def isInstanceOf[T0]: Boolean
    Definition Classes
      Any
17.  final def ne(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
18.  final def notify(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
19.  final def notifyAll(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
20.  var ret: Int

    The index for the selector when performing a number return action, then modified for the "next" index.

    The index for the selector when performing a number return action, then modified for the "next" index.

    Attributes
      protected
    Definition Classes
      NumberSelector
21.  var selectionIndex: Int

    The index for the selector when performing a number selection action, then modified to the "next" index.

    The index for the selector when performing a number selection action, then modified to the "next" index.

    Attributes
      protected
    Definition Classes
      NumberSelector
22.  final def synchronized[T0](arg0: => T0): T0
    Definition Classes
      AnyRef
23.  def toString(): String
    Definition Classes
      AnyRef → Any
24.  final def wait(): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.InterruptedException])
25.  final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.InterruptedException])
26.  final def wait(arg0: Long): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.InterruptedException]) @native()

### Inherited from NumberSelector

### Inherited from AnyRef

### Inherited from Any

### Ungrouped