Tanoda
Leap.Unity.Either< A, B > Struct Template Reference

A data structure that represents either a value of type A or a value of type B. The value can never be both A and B. Neither A nor B can ever be null. More...

Inheritance diagram for Leap.Unity.Either< A, B >:

Public Member Functions

 Either (A a)
 Constructs an Either with a value of A. More...
 
 Either (B b)
 Constructs an Either with a value of B. More...
 
void Match (Action< A > ifA, Action< B > ifB)
 Calls the first delegate with the value of A if it is present, else calls the second delegate with the value of B. More...
 
bool TryGetA (out A a)
 If this either contains the value of A, the out argument is filled with that value and this method returns true, else it returns false. More...
 
bool TryGetB (out B b)
 If this either contains the value of B, the out argument is filled with that value and this method returns true, else it returns false. More...
 
override int GetHashCode ()
 
override bool Equals (object obj)
 
bool Equals (Either< A, B > other)
 
int CompareTo (object obj)
 
int CompareTo (Either< A, B > other)
 

Static Public Member Functions

static bool operator== (Either< A, B > either0, Either< A, B > either1)
 
static bool operator!= (Either< A, B > either0, Either< A, B > either1)
 
static bool operator> (Either< A, B > either0, Either< A, B > either1)
 
static bool operator>= (Either< A, B > either0, Either< A, B > either1)
 
static bool operator< (Either< A, B > either0, Either< A, B > either1)
 
static bool operator<= (Either< A, B > either0, Either< A, B > either1)
 
static implicit operator Either< A, B > (A a)
 
static implicit operator Either< A, B > (B b)
 

Public Attributes

readonly bool isA
 Returns whether or not this Either contains the first value. More...
 

Properties

bool isB [get]
 Returns whether or not this Either contains the second value. More...
 
Maybe< A > a [get]
 Returns a Maybe that contains the value of A if it exists, or no value if it doesn't. More...
 
Maybe< B > b [get]
 Returns a Maybe that contains the value of B if it exists, or no value if it doesn't. More...
 

Detailed Description

A data structure that represents either a value of type A or a value of type B. The value can never be both A and B. Neither A nor B can ever be null.

Definition at line 18 of file Either.cs.

Constructor & Destructor Documentation

◆ Either() [1/2]

Leap.Unity.Either< A, B >.Either ( a)

Constructs an Either with a value of A.

Definition at line 68 of file Either.cs.

◆ Either() [2/2]

Leap.Unity.Either< A, B >.Either ( b)

Constructs an Either with a value of B.

Definition at line 81 of file Either.cs.

Member Function Documentation

◆ CompareTo() [1/2]

int Leap.Unity.Either< A, B >.CompareTo ( Either< A, B >  other)

Definition at line 155 of file Either.cs.

◆ CompareTo() [2/2]

int Leap.Unity.Either< A, B >.CompareTo ( object  obj)

Definition at line 147 of file Either.cs.

◆ Equals() [1/2]

bool Leap.Unity.Either< A, B >.Equals ( Either< A, B >  other)

Definition at line 137 of file Either.cs.

◆ Equals() [2/2]

override bool Leap.Unity.Either< A, B >.Equals ( object  obj)

Definition at line 129 of file Either.cs.

◆ GetHashCode()

override int Leap.Unity.Either< A, B >.GetHashCode ( )

Definition at line 121 of file Either.cs.

◆ Match()

void Leap.Unity.Either< A, B >.Match ( Action< A >  ifA,
Action< B >  ifB 
)

Calls the first delegate with the value of A if it is present, else calls the second delegate with the value of B.

Definition at line 95 of file Either.cs.

◆ operator Either< A, B >() [1/2]

static implicit Leap.Unity.Either< A, B >.operator Either< A, B > ( a)
static

Definition at line 209 of file Either.cs.

◆ operator Either< A, B >() [2/2]

static implicit Leap.Unity.Either< A, B >.operator Either< A, B > ( b)
static

Definition at line 213 of file Either.cs.

◆ operator!=()

static bool Leap.Unity.Either< A, B >.operator!= ( Either< A, B >  either0,
Either< A, B >  either1 
)
static

Definition at line 189 of file Either.cs.

◆ operator<()

static bool Leap.Unity.Either< A, B >.operator< ( Either< A, B >  either0,
Either< A, B >  either1 
)
static

Definition at line 201 of file Either.cs.

◆ operator<=()

static bool Leap.Unity.Either< A, B >.operator<= ( Either< A, B >  either0,
Either< A, B >  either1 
)
static

Definition at line 205 of file Either.cs.

◆ operator==()

static bool Leap.Unity.Either< A, B >.operator== ( Either< A, B >  either0,
Either< A, B >  either1 
)
static

Definition at line 185 of file Either.cs.

◆ operator>()

static bool Leap.Unity.Either< A, B >.operator> ( Either< A, B >  either0,
Either< A, B >  either1 
)
static

Definition at line 193 of file Either.cs.

◆ operator>=()

static bool Leap.Unity.Either< A, B >.operator>= ( Either< A, B >  either0,
Either< A, B >  either1 
)
static

Definition at line 197 of file Either.cs.

◆ TryGetA()

bool Leap.Unity.Either< A, B >.TryGetA ( out A  a)

If this either contains the value of A, the out argument is filled with that value and this method returns true, else it returns false.

Definition at line 107 of file Either.cs.

◆ TryGetB()

bool Leap.Unity.Either< A, B >.TryGetB ( out B  b)

If this either contains the value of B, the out argument is filled with that value and this method returns true, else it returns false.

Definition at line 116 of file Either.cs.

Member Data Documentation

◆ isA

readonly bool Leap.Unity.Either< A, B >.isA

Returns whether or not this Either contains the first value.

Definition at line 23 of file Either.cs.

Property Documentation

◆ a

Maybe<A> Leap.Unity.Either< A, B >.a
get

Returns a Maybe that contains the value of A if it exists, or no value if it doesn't.

Definition at line 41 of file Either.cs.

◆ b

Maybe<B> Leap.Unity.Either< A, B >.b
get

Returns a Maybe that contains the value of B if it exists, or no value if it doesn't.

Definition at line 55 of file Either.cs.

◆ isB

bool Leap.Unity.Either< A, B >.isB
get

Returns whether or not this Either contains the second value.

Definition at line 28 of file Either.cs.


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