net.sf.jga.fn.arithmetic
Class ShiftRight<T extends java.lang.Number>

java.lang.Object
  extended by net.sf.jga.fn.Functor<R>
      extended by net.sf.jga.fn.BinaryFunctor<T,java.lang.Integer,T>
          extended by net.sf.jga.fn.arithmetic.ShiftRight<T>
All Implemented Interfaces:
java.io.Serializable, Visitable

public class ShiftRight<T extends java.lang.Number>
extends BinaryFunctor<T,java.lang.Integer,T>

Returns the first argument shifted right by the number of places given in the second argument.

Copyright © 2003-2005 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface ShiftRight.Visitor
          Interface for classes that may interpret a ShiftRight functor.
 
Constructor Summary
ShiftRight(java.lang.Class<T> c)
          Builds ShiftRight functor for the given class.
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(ShiftRight) method, if it implements the nested Visitor interface.
 T fn(T x, java.lang.Integer y)
          Given integral arguments x and y, returns x >> y
 java.lang.Class<T> getType()
          Returns the type of operands this instance supports
 java.lang.String toString()
           
 
Methods inherited from class net.sf.jga.fn.BinaryFunctor
bind, bind0th, bind1st, bind2nd, bindNth, compose, compose, composeNth, distribute, eval, generate, generate1st, generate2nd, generateNth
 
Methods inherited from class net.sf.jga.fn.Functor
composeNth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ShiftRight

public ShiftRight(java.lang.Class<T> c)
Builds ShiftRight functor for the given class. The class argument must be the same as the generic class argument (when generics are in use) or else a ClassCastException will be thrown when the functor is used.

Throws:
java.lang.IllegalArgumentException - if the given class has no Arithmetic implementation registered with the ArithmeticFactory
Method Detail

getType

public java.lang.Class<T> getType()
Returns the type of operands this instance supports


fn

public T fn(T x,
            java.lang.Integer y)
Given integral arguments x and y, returns x >> y

Specified by:
fn in class BinaryFunctor<T extends java.lang.Number,java.lang.Integer,T extends java.lang.Number>
Returns:
returns x >> y

accept

public void accept(Visitor v)
Calls the Visitor's visit(ShiftRight) method, if it implements the nested Visitor interface.

Specified by:
accept in interface Visitable
Overrides:
accept in class Functor<T extends java.lang.Number>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2002-2006 David A. Hall. All Rights Reserved.