Kerbal Space Program  1.12.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Public Member Functions | Public Attributes | Properties | List of all members
BiDictionaryOneToOne< TFirst, TSecond > Class Template Reference

This is a dictionary guaranteed to have only one of each value and key. It may be searched either by TFirst or by TSecond, giving a unique answer because it is 1 to 1. More...

Public Member Functions

void Add (TFirst first, TSecond second)
 Tries to add the pair to the dictionary. Throws an exception if either element is already in the dictionary More...
 
void Clear ()
 Removes all items from the dictionary. More...
 
TSecond GetByFirst (TFirst first)
 Find the TSecond corresponding to the TFirst first Throws an exception if first is not in the dictionary. More...
 
TFirst GetBySecond (TSecond second)
 Find the TFirst corresponing to the Second second. Throws an exception if second is not in the dictionary. More...
 
void RemoveByFirst (TFirst first)
 Remove the record containing first. If first is not in the dictionary, throws an Exception. More...
 
void RemoveBySecond (TSecond second)
 Remove the record containing second. If second is not in the dictionary, throws an Exception. More...
 
Boolean TryAdd (TFirst first, TSecond second)
 Tries to add the pair to the dictionary. Returns false if either element is already in the dictionary More...
 
Boolean TryGetByFirst (TFirst first, out TSecond second)
 Find the TSecond corresponding to the TFirst first. Returns false if first is not in the dictionary. More...
 
Boolean TryGetBySecond (TSecond second, out TFirst first)
 Find the TFirst corresponding to the TSecond second. Returns false if second is not in the dictionary. More...
 
Boolean TryRemoveByFirst (TFirst first)
 Remove the record containing first, if there is one. More...
 
Boolean TryRemoveBySecond (TSecond second)
 Remove the record containing second, if there is one. More...
 

Public Attributes

IDictionary< TFirst, TSecond > firstToSecond = new Dictionary<TFirst, TSecond>()
 
IDictionary< TSecond, TFirst > secondToFirst = new Dictionary<TSecond, TFirst>()
 

Properties

Int32 Count [get]
 The number of pairs stored in the dictionary More...
 

Detailed Description

This is a dictionary guaranteed to have only one of each value and key. It may be searched either by TFirst or by TSecond, giving a unique answer because it is 1 to 1.

Template Parameters
TFirstThe type of the "key"
TSecondThe type of the "value"

Member Function Documentation

void BiDictionaryOneToOne< TFirst, TSecond >.Add ( TFirst  first,
TSecond  second 
)
inline

Tries to add the pair to the dictionary. Throws an exception if either element is already in the dictionary

Parameters
first
second
void BiDictionaryOneToOne< TFirst, TSecond >.Clear ( )
inline

Removes all items from the dictionary.

TSecond BiDictionaryOneToOne< TFirst, TSecond >.GetByFirst ( TFirst  first)
inline

Find the TSecond corresponding to the TFirst first Throws an exception if first is not in the dictionary.

Parameters
firstthe key to search for
Returns
the value corresponding to first
TFirst BiDictionaryOneToOne< TFirst, TSecond >.GetBySecond ( TSecond  second)
inline

Find the TFirst corresponing to the Second second. Throws an exception if second is not in the dictionary.

Parameters
secondthe key to search for
Returns
the value corresponding to second
void BiDictionaryOneToOne< TFirst, TSecond >.RemoveByFirst ( TFirst  first)
inline

Remove the record containing first. If first is not in the dictionary, throws an Exception.

Parameters
firstthe key of the record to delete
void BiDictionaryOneToOne< TFirst, TSecond >.RemoveBySecond ( TSecond  second)
inline

Remove the record containing second. If second is not in the dictionary, throws an Exception.

Parameters
secondthe key of the record to delete
Boolean BiDictionaryOneToOne< TFirst, TSecond >.TryAdd ( TFirst  first,
TSecond  second 
)
inline

Tries to add the pair to the dictionary. Returns false if either element is already in the dictionary

Parameters
first
second
Returns
true if successfully added, false if either element are already in the dictionary
Boolean BiDictionaryOneToOne< TFirst, TSecond >.TryGetByFirst ( TFirst  first,
out TSecond  second 
)
inline

Find the TSecond corresponding to the TFirst first. Returns false if first is not in the dictionary.

Parameters
firstthe key to search for
secondthe corresponding value
Returns
true if first is in the dictionary, false otherwise
Boolean BiDictionaryOneToOne< TFirst, TSecond >.TryGetBySecond ( TSecond  second,
out TFirst  first 
)
inline

Find the TFirst corresponding to the TSecond second. Returns false if second is not in the dictionary.

Parameters
secondthe key to search for
firstthe corresponding value
Returns
true if second is in the dictionary, false otherwise
Boolean BiDictionaryOneToOne< TFirst, TSecond >.TryRemoveByFirst ( TFirst  first)
inline

Remove the record containing first, if there is one.

Parameters
first
Returns
If first is not in the dictionary, returns false, otherwise true
Boolean BiDictionaryOneToOne< TFirst, TSecond >.TryRemoveBySecond ( TSecond  second)
inline

Remove the record containing second, if there is one.

Parameters
second
Returns
If second is not in the dictionary, returns false, otherwise true

Member Data Documentation

IDictionary<TFirst, TSecond> BiDictionaryOneToOne< TFirst, TSecond >.firstToSecond = new Dictionary<TFirst, TSecond>()
IDictionary<TSecond, TFirst> BiDictionaryOneToOne< TFirst, TSecond >.secondToFirst = new Dictionary<TSecond, TFirst>()

Property Documentation

Int32 BiDictionaryOneToOne< TFirst, TSecond >.Count
get

The number of pairs stored in the dictionary


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