PeterO.Util

## PeterO.Util

public static class Util

Not documented yet.

Member Summary

### NullDisposable

public static readonly System.IDisposable NullDisposable;

An IDisposable object that does nothing when disposed.

### AddIfMissing

public static void AddIfMissing<T>(
    this System.Collections.Generic.IList<T> dict,
    T value);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: dict.AddIfMissing<T>(value) . If the object’s class already has a AddIfMissing method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: dict.AddIfMissing<T>(value) . If the object’s class already has a AddIfMissing<T> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Exceptions:

### AddIfMissing

public static void AddIfMissing<TKey, TValue>(
    this System.Collections.Generic.IDictionary<TKey, TValue> dict,
    TKey key,
    TValue value);

Adds if missing. In the.NET implementation, this method is implemented as an extension method to any object implementing IDictionary and can be called as follows: dict.AddIfMissing<TKey, TValue>(key, value) . If the object’s class already has a AddIfMissing<TKey, TValue> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Exceptions:

### AddOverwrite

public static void AddOverwrite<TKey, TValue>(
    this System.Collections.Generic.IDictionary<TKey, TValue> dict,
    TKey key,
    TValue value);

Adds the overwrite. In the.NET implementation, this method is implemented as an extension method to any object implementing IDictionary and can be called as follows: dict.AddOverwrite<TKey, TValue>(key, value) . If the object’s class already has a AddOverwrite<TKey, TValue> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Exceptions:

### AllSame

public static bool AllSame<T>(
    this System.Collections.Generic.IEnumerable<T> col);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IEnumerable and can be called as follows: col.AllSame<T>() . If the object’s class already has a AllSame method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing IEnumerable and can be called as follows: col.AllSame<T>() . If the object’s class already has a AllSame<T> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

Either true or false .

Exceptions:

### AllSame

public static bool AllSame<TContainer, TItem>(
    this System.Collections.Generic.IEnumerable<TContainer> containers,
    System.Func<TContainer, TItem> func);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IEnumerable and can be called as follows: containers.AllSame<TContainer, TItem>(func) . If the object’s class already has a AllSame<TContainer, TItem> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

Either true or false .

Exceptions:

### ArrayToString

public static string ArrayToString<T>(
    this System.Collections.Generic.IEnumerable<T> array);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IEnumerable and can be called as follows: array.ArrayToString<T>() . If the object’s class already has a ArrayToString method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing IEnumerable and can be called as follows: array.ArrayToString<T>() . If the object’s class already has a ArrayToString<T> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

A text string.

### CopyStream

public static void CopyStream(
    this System.IO.Stream input,
    int length,
    System.IO.Stream output);

Copies a certain number of bytes from one stream to another. In the.NET implementation, this method is implemented as an extension method to any object implementing Stream and can be called as follows: input.CopyStream(length, output) . If the object’s class already has a CopyStream method with the same parameters, that method takes precedence over this extension method.

Parameters:

Exceptions:

### CopyStream

public static void CopyStream(
    this System.IO.Stream input,
    System.IO.Stream output);

Copies all bytes from one stream to another. In the.NET implementation, this method is implemented as an extension method to any object implementing Stream and can be called as follows: input.CopyStream(output) . If the object’s class already has a CopyStream method with the same parameters, that method takes precedence over this extension method.

Parameters:

Exceptions:

### CopyStructure

public static T CopyStructure<T>(
    this T structure)
    where T : new(), PeterO.IStructureT;

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing T and can be called as follows: structure.CopyStructure<T>() . If the object’s class already has a CopyStructure method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing T and can be called as follows: structure.CopyStructure<T>() . If the object’s class already has a CopyStructure<T> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

A T object.

Exceptions:

### EachWithIndex

public static System.Collections.Generic.IEnumerable<PeterO.Pair<T, int>> EachWithIndex<T>(
    this System.Collections.Generic.IEnumerable<T> arr);

Not documented yet.

Parameters:

Return Value:

When enumerated, outputs the item and its index (starting at 0), in that order.

### GetSegment

public static PeterO.ListSegment<T> GetSegment<T>(
    this System.Collections.Generic.IList<T> list,
    int start);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.GetSegment<T>(start) . If the object’s class already has a GetSegment method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.GetSegment<T>(start) . If the object’s class already has a GetSegment<T> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

A ListSegment(T) object.

Exceptions:

### GetSegment

public static PeterO.ListSegment<T> GetSegment<T>(
    this System.Collections.Generic.IList<T> list,
    int start,
    int count);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.GetSegment<T>(start, count) . If the object’s class already has a GetSegment method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.GetSegment<T>(start, count) . If the object’s class already has a GetSegment<T> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

A ListSegment(T) object.

Exceptions:

### HasUnique

public static bool HasUnique<T>(
    this System.Collections.Generic.IEnumerable<T> col);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IEnumerable and can be called as follows: col.HasUnique<T>() . If the object’s class already has a HasUnique method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing IEnumerable and can be called as follows: col.HasUnique<T>() . If the object’s class already has a HasUnique<T> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

Either true or false .

Exceptions:

### HasUnique

public static bool HasUnique<TContainer, TItem>(
    this System.Collections.Generic.IEnumerable<TContainer> containers,
    System.Func<TContainer, TItem> func);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IEnumerable and can be called as follows: containers.HasUnique<TContainer, TItem>(func) . If the object’s class already has a HasUnique<TContainer, TItem> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

Either true or false .

Exceptions:

### Implode

public static string Implode<T>(
    this System.Collections.Generic.IEnumerable<T> col,
    string separator);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IEnumerable and can be called as follows: col.Implode<T>(separator) . If the object’s class already has a Implode method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing IEnumerable and can be called as follows: col.Implode<T>(separator) . If the object’s class already has a Implode<T> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

A text string.

Exceptions:

### IndexOf

public static int IndexOf<T>(
    this System.Collections.Generic.IList<T> list,
    System.Predicate<T> match);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.IndexOf<T>(match) . If the object’s class already has a IndexOf method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.IndexOf<T>(match) . If the object’s class already has a IndexOf<T> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

A 32-bit signed integer.

Exceptions:

### IndexOf

public static int IndexOf<T>(
    this System.Collections.Generic.IList<T> list,
    T obj);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.IndexOf<T>(obj) . If the object’s class already has a IndexOf method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.IndexOf<T>(obj) . If the object’s class already has a IndexOf<T> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

A 32-bit signed integer.

Exceptions:

### MakePair

public static PeterO.Pair<TFirst, TSecond> MakePair<TFirst, TSecond>(
    TFirst f,
    TSecond s);

Not documented yet.

Parameters:

Return Value:

A Pair(TFirst, TSecond) object.

### MaxOrDefault

public static T MaxOrDefault<T>(
    this System.Collections.Generic.IEnumerable<T> coll)
    where T : System.IComparable<T>T;

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IEnumerable and can be called as follows: coll.MaxOrDefault<T>() . If the object’s class already has a MaxOrDefault method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing IEnumerable and can be called as follows: coll.MaxOrDefault<T>() . If the object’s class already has a MaxOrDefault<T> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

A T object.

Exceptions:

### MinOrDefault

public static T MinOrDefault<T>(
    this System.Collections.Generic.IEnumerable<T> coll)
    where T : System.IComparable<T>T;

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IEnumerable and can be called as follows: coll.MinOrDefault<T>() . If the object’s class already has a MinOrDefault method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing IEnumerable and can be called as follows: coll.MinOrDefault<T>() . If the object’s class already has a MinOrDefault<T> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

A T object.

Exceptions:

### RemoveAll

public static int RemoveAll<T>(
    this System.Collections.Generic.IList<T> list,
    System.Predicate<T> match);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.RemoveAll<T>(match) . If the object’s class already has a RemoveAll method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.RemoveAll<T>(match) . If the object’s class already has a RemoveAll<T> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

A 32-bit signed integer.

Exceptions:

### SetIfMissing

public static T SetIfMissing<T>(
    this System.Collections.Generic.IList<T> list,
    int index,
    System.Func<T> valuefunc);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.SetIfMissing<T>(index, valuefunc) . If the object’s class already has a SetIfMissing method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.SetIfMissing<T>(index, valuefunc) . If the object’s class already has a SetIfMissing<T> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

A T object.

Exceptions:

### SetIfMissing

public static T SetIfMissing<T>(
    this System.Collections.Generic.IList<T> list,
    int index,
    T value);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.SetIfMissing<T>(index, value) . If the object’s class already has a SetIfMissing method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.SetIfMissing<T>(index, value) . If the object’s class already has a SetIfMissing<T> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

A T object.

Exceptions:

### SetNewIfMissing

public static T SetNewIfMissing<T>(
    this System.Collections.Generic.IList<T> list,
    int index)
    where T : new()T;

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.SetNewIfMissing<T>(index) . If the object’s class already has a SetNewIfMissing method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

A T object.

Exceptions:

### SetValue

public static void SetValue<T>(
    this System.Collections.Generic.IList<T> list,
    int index,
    T value);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.SetValue<T>(index, value) . If the object’s class already has a SetValue method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.SetValue<T>(index, value) . If the object’s class already has a SetValue<T> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Exceptions:

### StructureSize

public static int StructureSize(
    this PeterO.IStructure s);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IStructure and can be called as follows: s.StructureSize() . If the object’s class already has a StructureSize method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing IStructure and can be called as follows: s.StructureSize() . If the object’s class already has a StructureSize method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

A 32-bit signed integer.

Exceptions:

### Sum

public static int Sum<T>(
    this System.Collections.Generic.IEnumerable<T> containers,
    System.Func<T, int> func);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IEnumerable and can be called as follows: containers.Sum<T>(func) . If the object’s class already has a Sum method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

A 32-bit signed integer.

### Transform

public static System.Collections.Generic.IEnumerable<TOutput> Transform<TInput, TOutput>(
    this System.Collections.Generic.IEnumerable<TInput> containers,
    System.Func<TInput, TOutput> func);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IEnumerable and can be called as follows: containers.Transform<TInput, TOutput>(func) . If the object’s class already has a Transform<TInput, TOutput> method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

The transform.

### UpToExcluding

public static System.Collections.Generic.IEnumerable UpToExcluding(
    this int minValue,
    int maxValue);

Creates an iterator of integers starting at a minimum value and ending at one less than the maximum. In the.NET implementation, this method is implemented as an extension method to any object implementing Int32 and can be called as follows: minValue.UpToExcluding(maxValue) . If the object’s class already has a UpToExcluding method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing Int32 and can be called as follows: minValue.UpToExcluding(maxValue) . If the object’s class already has a UpToExcluding method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

An IEnumerable(int) object.

Exceptions:

### UpToIncluding

public static System.Collections.Generic.IEnumerable UpToIncluding(
    this int minValue,
    int maxValue);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing Int32 and can be called as follows: minValue.UpToIncluding(maxValue) . If the object’s class already has a UpToIncluding method with the same parameters, that method takes precedence over this extension method.

In the.NET implementation, this method is implemented as an extension method to any object implementing Int32 and can be called as follows: minValue.UpToIncluding(maxValue) . If the object’s class already has a UpToIncluding method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

An IEnumerable(int) object.

### ValueOrDefault

public static T ValueOrDefault<T>(
    this System.Collections.Generic.IList<T> list,
    int index);

Not documented yet. In the.NET implementation, this method is implemented as an extension method to any object implementing IList and can be called as follows: list.ValueOrDefault<T>(index) . If the object’s class already has a ValueOrDefault method with the same parameters, that method takes precedence over this extension method.

Parameters:

Return Value:

A T object.

Exceptions:

Back to petero-csharp start page.