Wintellect.PowerCollections Namespace
Algorithms Class
GhostDoc Pro Sample Help File

Bag<(Of <(<'T>)>)>..::..Sum Method

Computes the sum of this bag with another bag. he sum of two bags is all items from both of the bags. If an item appears X times in one bag, and Y times in the other bag, the sum contains the item (X+Y) times. A new bag is created with the sum of the bags and is returned. This bag and the other bag are unchanged.

Namespace:  Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax


public Bag<T> Sum(
	Bag<T> otherBag
)
Public Function Sum ( _
	otherBag As Bag(Of T) _
) As Bag(Of T)
public:
Bag<T>^ Sum(
	Bag<T>^ otherBag
)

Parameters

otherBag
Type: Wintellect.PowerCollections..::..Bag<(Of <(<'T>)>)>
Bag to sum with.

Return Value

The sum of the two bags.

Exceptions


ExceptionCondition
InvalidOperationExceptionThis bag and otherBag don't use the same method for comparing items.

Remarks


The sum of two bags is computed in time O(M + N log M), where M is the size of the larger bag, and N is the size of the smaller bag.