Kerbal Space Program  1.12.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
Smooth.Algebraics.Option< T > Struct Template Reference

Struct representing an optional value of type T. An option that contains the value t is called a "Some" or "Some(t)". An empty option is called a "None". Option<T> can be thought of as a far more robust version of Nullable<T> or as an IEnumerable<T> that may contain exactly 0 or 1 element(s). More...

Inheritance diagram for Smooth.Algebraics.Option< T >:

Public Member Functions

Cata< U > (DelegateFunc< T, U > someFunc, U noneValue)
 If the option isSome, returns the result of someFunc applied to the option's value; otherwise, returns noneValue. More...
 
Cata< U > (DelegateFunc< T, U > someFunc, DelegateFunc< U > noneFunc)
 If the option isSome, returns the result of someFunc applied to the option's value; otherwise, returns the result of noneFunc. More...
 
Cata< U, P > (DelegateFunc< T, P, U > someFunc, P p, U noneValue)
 If the option isSome, returns the result of someFunc applied to the option's value and p; otherwise, returns noneValue. More...
 
Cata< U, P > (DelegateFunc< T, P, U > someFunc, P p, DelegateFunc< U > noneFunc)
 If the option isSome, returns the result of someFunc applied to the option's value and p; otherwise, returns the result of noneFunc. More...
 
Cata< U, P, P2 > (DelegateFunc< T, P, U > someFunc, P p, DelegateFunc< P2, U > noneFunc, P2 p2)
 If the option isSome, returns the result of someFunc applied to the option's value and p; otherwise, returns the result of noneFunc applied to p2. More...
 
int CompareTo (Option< T > other)
 
bool Contains (T t)
 Returns true if the option contains the specified value according to the default equality comparer; otherwise, false. More...
 
bool Contains (T t, IEqualityComparer< T > comparer)
 Returns true if the option contains the specified value according to the specified equality comparer; otherwise, false. More...
 
override bool Equals (object o)
 
bool Equals (Option< T > other)
 
void ForEach (DelegateAction< T > action)
 If the option isSome, invokes the specified delegate with the option's value; otherwise, does nothing. More...
 
void ForEach< P > (DelegateAction< T, P > action, P p)
 If the option isSome, invokes the specified delegate with the option's value and p; otherwise, does nothing. More...
 
void ForEachOr (DelegateAction< T > someAction, DelegateAction noneAction)
 If the option isSome, invokes the someAction with the option's value; otherwise, invokes noneAction. More...
 
void ForEachOr< P > (DelegateAction< T, P > someAction, P p, DelegateAction noneAction)
 If the option isSome, invokes the someAction with the option's value and p; otherwise, invokes noneAction. More...
 
void ForEachOr< P, P2 > (DelegateAction< T, P > someAction, P p, DelegateAction< P2 > noneAction, P2 p2)
 If the option isSome, invokes the someAction with the option's value and p; otherwise, invokes noneAction with p2. More...
 
void ForEachOr< P2 > (DelegateAction< T > someAction, DelegateAction< P2 > noneAction, P2 p2)
 If the option isSome, invokes the someAction with the option's value; otherwise, invokes noneAction with p2. More...
 
override int GetHashCode ()
 
void IfEmpty (DelegateAction action)
 If the option isNone, invokes the specified delegate; otherwise, does nothing. More...
 
void IfEmpty< P > (DelegateAction< P > action, P p)
 If the option isNone, invokes the specified delegate with p; otherwise, does nothing. More...
 
 Option (T value)
 Creates a Some option that contains the specified value. More...
 
Option< T > Or (Option< T > noneOption)
 If the option isSome, returns the option; otherwise, returns noneOption. More...
 
Option< T > Or (DelegateFunc< Option< T >> noneFunc)
 If the option isSome, returns the option; otherwise, returns the result of noneFunc. More...
 
Option< T > Or< P > (DelegateFunc< P, Option< T >> noneFunc, P p)
 If the option isSome, returns the option; otherwise, returns the result of noneFunc applied to p. More...
 
Option< U > Select< U > (DelegateFunc< T, U > selector)
 If the option isSome, returns an option containing the specified selector applied to the option's value; otherwise, returns an empty option. More...
 
Option< U > Select< U, P > (DelegateFunc< T, P, U > selector, P p)
 If the option isSome, returns an option containing the specified selector applied to the option's value and p; otherwise, returns an empty option. More...
 
Option< U > SelectMany< U > (DelegateFunc< T, Option< U >> selector)
 If the option isSome, returns the specified selector applied to the option's value; otherwise, returns an empty option. More...
 
Option< U > SelectMany< U, P > (DelegateFunc< T, P, Option< U >> selector, P p)
 If the option isSome, returns the specified selector applied to the option's value and p; otherwise, returns an empty option. More...
 
override string ToString ()
 
ValueOr (T noneValue)
 If the option isSome, returns the option's value; otherwise, returns noneValue. More...
 
ValueOr (DelegateFunc< T > noneFunc)
 If the option isSome, returns the option's value; otherwise, returns the result of noneFunc. More...
 
ValueOr< P > (DelegateFunc< P, T > noneFunc, P p)
 If the option isSome, returns the option's value; otherwise, returns the result of noneFunc applied to p. More...
 
Option< T > Where (DelegateFunc< T, bool > predicate)
 If the option isSome and the specified predicate applied to the option's value is true, returns the option; otherwise, returns an empty option. More...
 
Option< T > Where< P > (DelegateFunc< T, P, bool > predicate, P p)
 If the option isSome and the specified predicate applied to the option's value and p is true, returns the option; otherwise, returns an empty option. More...
 
Option< T > WhereNot (DelegateFunc< T, bool > predicate)
 If the option isSome and the specified predicate applied to the option's value is false, returns the option; otherwise, returns an empty option. More...
 
Option< T > WhereNot< P > (DelegateFunc< T, P, bool > predicate, P p)
 If the option isSome and the specified predicate applied to the option's value and p is false, returns the option; otherwise, returns an empty option. More...
 

Static Public Member Functions

static bool operator!= (Option< T > lhs, Option< T > rhs)
 
static bool operator< (Option< T > lhs, Option< T > rhs)
 
static bool operator<= (Option< T > lhs, Option< T > rhs)
 
static bool operator== (Option< T > lhs, Option< T > rhs)
 
static bool operator> (Option< T > lhs, Option< T > rhs)
 
static bool operator>= (Option< T > lhs, Option< T > rhs)
 

Public Attributes

readonly bool isSome
 True if the option contains a value; otherwise, false. More...
 
readonly T value
 If the option isSome, the value contained by the option; otherwise, default(T). More...
 

Static Public Attributes

static readonly Option< T > None = new Option<T>()
 A static None option for type T. More...
 

Properties

bool isNone [get]
 True if the option is empty; otherwise, false. More...
 

Detailed Description

Struct representing an optional value of type T. An option that contains the value t is called a "Some" or "Some(t)". An empty option is called a "None". Option<T> can be thought of as a far more robust version of Nullable<T> or as an IEnumerable<T> that may contain exactly 0 or 1 element(s).

An Option<T> has two fields:

public readonly bool isSome;

public readonly T value;

Use the isSome field to determine if the option contains a value, and the value field to read the value. Nothing prevents access to the value field of an empty option, it is up to the user to adherere to the Some / None semantics.

Constructor & Destructor Documentation

Smooth.Algebraics.Option< T >.Option ( value)
inline

Creates a Some option that contains the specified value.

Note: Use the default contructor to create a None option.

Member Function Documentation

U Smooth.Algebraics.Option< T >.Cata< U > ( DelegateFunc< T, U >  someFunc,
noneValue 
)
inline

If the option isSome, returns the result of someFunc applied to the option's value; otherwise, returns noneValue.

U Smooth.Algebraics.Option< T >.Cata< U > ( DelegateFunc< T, U >  someFunc,
DelegateFunc< U >  noneFunc 
)
inline

If the option isSome, returns the result of someFunc applied to the option's value; otherwise, returns the result of noneFunc.

U Smooth.Algebraics.Option< T >.Cata< U, P > ( DelegateFunc< T, P, U >  someFunc,
p,
noneValue 
)
inline

If the option isSome, returns the result of someFunc applied to the option's value and p; otherwise, returns noneValue.

U Smooth.Algebraics.Option< T >.Cata< U, P > ( DelegateFunc< T, P, U >  someFunc,
p,
DelegateFunc< U >  noneFunc 
)
inline

If the option isSome, returns the result of someFunc applied to the option's value and p; otherwise, returns the result of noneFunc.

U Smooth.Algebraics.Option< T >.Cata< U, P, P2 > ( DelegateFunc< T, P, U >  someFunc,
p,
DelegateFunc< P2, U >  noneFunc,
P2  p2 
)
inline

If the option isSome, returns the result of someFunc applied to the option's value and p; otherwise, returns the result of noneFunc applied to p2.

int Smooth.Algebraics.Option< T >.CompareTo ( Option< T >  other)
inline
bool Smooth.Algebraics.Option< T >.Contains ( t)
inline

Returns true if the option contains the specified value according to the default equality comparer; otherwise, false.

bool Smooth.Algebraics.Option< T >.Contains ( t,
IEqualityComparer< T >  comparer 
)
inline

Returns true if the option contains the specified value according to the specified equality comparer; otherwise, false.

override bool Smooth.Algebraics.Option< T >.Equals ( object  o)
inline
bool Smooth.Algebraics.Option< T >.Equals ( Option< T >  other)
inline
void Smooth.Algebraics.Option< T >.ForEach ( DelegateAction< T >  action)
inline

If the option isSome, invokes the specified delegate with the option's value; otherwise, does nothing.

void Smooth.Algebraics.Option< T >.ForEach< P > ( DelegateAction< T, P >  action,
p 
)
inline

If the option isSome, invokes the specified delegate with the option's value and p; otherwise, does nothing.

void Smooth.Algebraics.Option< T >.ForEachOr ( DelegateAction< T >  someAction,
DelegateAction  noneAction 
)
inline

If the option isSome, invokes the someAction with the option's value; otherwise, invokes noneAction.

void Smooth.Algebraics.Option< T >.ForEachOr< P > ( DelegateAction< T, P >  someAction,
p,
DelegateAction  noneAction 
)
inline

If the option isSome, invokes the someAction with the option's value and p; otherwise, invokes noneAction.

void Smooth.Algebraics.Option< T >.ForEachOr< P, P2 > ( DelegateAction< T, P >  someAction,
p,
DelegateAction< P2 >  noneAction,
P2  p2 
)
inline

If the option isSome, invokes the someAction with the option's value and p; otherwise, invokes noneAction with p2.

void Smooth.Algebraics.Option< T >.ForEachOr< P2 > ( DelegateAction< T >  someAction,
DelegateAction< P2 >  noneAction,
P2  p2 
)
inline

If the option isSome, invokes the someAction with the option's value; otherwise, invokes noneAction with p2.

override int Smooth.Algebraics.Option< T >.GetHashCode ( )
inline
void Smooth.Algebraics.Option< T >.IfEmpty ( DelegateAction  action)
inline

If the option isNone, invokes the specified delegate; otherwise, does nothing.

void Smooth.Algebraics.Option< T >.IfEmpty< P > ( DelegateAction< P >  action,
p 
)
inline

If the option isNone, invokes the specified delegate with p; otherwise, does nothing.

static bool Smooth.Algebraics.Option< T >.operator!= ( Option< T >  lhs,
Option< T >  rhs 
)
inlinestatic
static bool Smooth.Algebraics.Option< T >.operator< ( Option< T >  lhs,
Option< T >  rhs 
)
inlinestatic
static bool Smooth.Algebraics.Option< T >.operator<= ( Option< T >  lhs,
Option< T >  rhs 
)
inlinestatic
static bool Smooth.Algebraics.Option< T >.operator== ( Option< T >  lhs,
Option< T >  rhs 
)
inlinestatic
static bool Smooth.Algebraics.Option< T >.operator> ( Option< T >  lhs,
Option< T >  rhs 
)
inlinestatic
static bool Smooth.Algebraics.Option< T >.operator>= ( Option< T >  lhs,
Option< T >  rhs 
)
inlinestatic
Option<T> Smooth.Algebraics.Option< T >.Or ( Option< T >  noneOption)
inline

If the option isSome, returns the option; otherwise, returns noneOption.

Option<T> Smooth.Algebraics.Option< T >.Or ( DelegateFunc< Option< T >>  noneFunc)
inline

If the option isSome, returns the option; otherwise, returns the result of noneFunc.

Option<T> Smooth.Algebraics.Option< T >.Or< P > ( DelegateFunc< P, Option< T >>  noneFunc,
p 
)
inline

If the option isSome, returns the option; otherwise, returns the result of noneFunc applied to p.

Option<U> Smooth.Algebraics.Option< T >.Select< U > ( DelegateFunc< T, U >  selector)
inline

If the option isSome, returns an option containing the specified selector applied to the option's value; otherwise, returns an empty option.

Option<U> Smooth.Algebraics.Option< T >.Select< U, P > ( DelegateFunc< T, P, U >  selector,
p 
)
inline

If the option isSome, returns an option containing the specified selector applied to the option's value and p; otherwise, returns an empty option.

Option<U> Smooth.Algebraics.Option< T >.SelectMany< U > ( DelegateFunc< T, Option< U >>  selector)
inline

If the option isSome, returns the specified selector applied to the option's value; otherwise, returns an empty option.

Option<U> Smooth.Algebraics.Option< T >.SelectMany< U, P > ( DelegateFunc< T, P, Option< U >>  selector,
p 
)
inline

If the option isSome, returns the specified selector applied to the option's value and p; otherwise, returns an empty option.

override string Smooth.Algebraics.Option< T >.ToString ( )
inline
T Smooth.Algebraics.Option< T >.ValueOr ( noneValue)
inline

If the option isSome, returns the option's value; otherwise, returns noneValue.

T Smooth.Algebraics.Option< T >.ValueOr ( DelegateFunc< T >  noneFunc)
inline

If the option isSome, returns the option's value; otherwise, returns the result of noneFunc.

T Smooth.Algebraics.Option< T >.ValueOr< P > ( DelegateFunc< P, T >  noneFunc,
p 
)
inline

If the option isSome, returns the option's value; otherwise, returns the result of noneFunc applied to p.

Option<T> Smooth.Algebraics.Option< T >.Where ( DelegateFunc< T, bool >  predicate)
inline

If the option isSome and the specified predicate applied to the option's value is true, returns the option; otherwise, returns an empty option.

Option<T> Smooth.Algebraics.Option< T >.Where< P > ( DelegateFunc< T, P, bool >  predicate,
p 
)
inline

If the option isSome and the specified predicate applied to the option's value and p is true, returns the option; otherwise, returns an empty option.

Option<T> Smooth.Algebraics.Option< T >.WhereNot ( DelegateFunc< T, bool >  predicate)
inline

If the option isSome and the specified predicate applied to the option's value is false, returns the option; otherwise, returns an empty option.

Option<T> Smooth.Algebraics.Option< T >.WhereNot< P > ( DelegateFunc< T, P, bool >  predicate,
p 
)
inline

If the option isSome and the specified predicate applied to the option's value and p is false, returns the option; otherwise, returns an empty option.

Member Data Documentation

readonly bool Smooth.Algebraics.Option< T >.isSome

True if the option contains a value; otherwise, false.

readonly Option<T> Smooth.Algebraics.Option< T >.None = new Option<T>()
static

A static None option for type T.

readonly T Smooth.Algebraics.Option< T >.value

If the option isSome, the value contained by the option; otherwise, default(T).

Property Documentation

bool Smooth.Algebraics.Option< T >.isNone
get

True if the option is empty; otherwise, false.


The documentation for this struct was generated from the following file: