Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Standard C++ Library Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

set_difference()

Module:  Standard C++ Library   Library:  Algorithms


Function

Local Index

No Entries

Summary

A basic set operation (algorithm) for constructing a sorted difference

Synopsis

#include <algorithm>

namespace std {
  template <class InputIterator1, class InputIterator2,
            class OutputIterator>
  OutputIterator 
  set_difference(InputIterator1 start1,
                 InputIterator1 finish1,
                 InputIterator2 start2,
                 InputIterator2 finish2,
                 OutputIterator result);
  template <class InputIterator1, class InputIterator2,
            class OutputIterator, class Compare>
  OutputIterator 
  set_difference(InputIterator1 start1,
                 InputIterator1 finish1,
                 InputIterator2 start2,
                 InputIterator2 finish2,
                 OutputIterator result,
                 Compare comp);
}

Description

The set_difference() algorithm constructs a sorted difference that includes copies of the elements that are present in the range [start1, finish1) but are not present in the range [start2, finish2). It returns the end of the constructed range.

As an example, assume we have the following two sets:

1 2 3 4 5

and

3 4 5 6 7

The result of applying set_difference() is the set:

1 2

The result of set_difference() is undefined if the result range overlaps with either of the original ranges.

set_difference() assumes that the ranges are sorted using operator<(), unless an alternative comparison function object (comp) is provided.

Use the set_symetric_difference() algorithm to obtain a result that contains all elements that are not in common between the two sets.

Complexity

At most ((finish1 - start1) + (finish2 - start2)) * 2 -1 comparisons are performed.

Example

See Also

includes(), Iterators, set_union(), set_intersection(), set_symmetric_difference()

Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 25.3.5.4



Previous fileTop of DocumentContentsIndex pageNext file

Copyright (c) 1994-2006 Rogue Wave Software, a Quovadx Division.
Licensed under the Apache License, Version 2.0.
Contact Rogue Wave about documentation or support issues. You can also seek help from other developers through the Apache stdcxx community (see below).

For more information on the Rogue Wave Standard C++ Library under open source, see Section 1.2 of the user's guide.