## .\

# cgsetintersection.pro

## top cgSetIntersection

Utilities

`result = cgSetIntersection(set_a, set_b [, COUNT=integer] [, INDICES_A=integer] [, INDICES_B=integer] [, NORESULT=NORESULT] [, POSITIONS=integer] [, /SUCCESS])`

This function is used to find the intersection between two sets of integers.

### Return value

A vector of values that are found in both set_a and set_b.

### Parameters

- set_a in required type=integer
A vector of integers.

- set_b in required type=integer
A vector of integers.

### Keywords

- COUNT out optional type=integer
This keyword contains the number of elements in the intersection vector.

- INDICES_A out optional type=integer
The indices in vector A where the intersected values appear. Note, this requires the intersected points be unique in each vector. The

`Positions`

keyword will return ALL the positions of the match, even if there are non-unique matches.- INDICES_B out optional type=integer
The indices in vector B where the intersected values appear. This assumes that the intersected points are represented uniquely in the A and B vectors.

- NORESULT in optional
Set this keyword to a value that will be returned from the function if no intersection between the two sets of numbers is found. By default, -1.

- POSITIONS out optional type=integer
This keyword returns the positions or locations in A where the values in B appear.

- SUCCESS out optional type=boolean
This keyword is set to 1 if an intersection was found, and to 0 otherwise.

### Examples

Here is how to use this program:

```
IDL> set_a = [1,2,3,4,5]
IDL> set_b = [4,5,6,7,8,9,10,11]
IDL> Print, cgSetIntersection(set_a, set_b)
4 5
```

### Author information

- Author:
FANNING SOFTWARE CONSULTING:

`David W. Fanning 1645 Sheely Drive Fort Collins, CO 80526 USA Phone: 970-221-0438 E-mail: david@idlcoyote.com Coyote's Guide to IDL Programming: http://www.idlcoyote.com`

- Copyright:
Copyright (c) 2009-2013, Fanning Software Consulting, Inc.

- History:
Change History:

`Written by: David W. Fanning, October 31, 2009, from code originally supplied to the IDL newsgroup by Research Systems software engineers. Yikes, bug in original code only allowed positive integers. Fixed now. 2 Nov 2009. DWF. Fixed a problem when one or both of the sets was a scalar value. 18 Nov 2009. DWF. Added a POSITIONS keyword. 30 Nov 2012. DWF. Added a COUNT keyword 3 Dec 2012. DWF. Added INDICES_A and INDICES_B keywords at R.G. Stockwell's suggestion. 13 Dec 2012. DWF.`

## File attributes

Modification date: | Fri Mar 27 11:07:37 2015 |

Lines: | 197 |

Docformat: | rst rst |