CodeSonar C++ API
[For improved navigation, enable JavaScript.]
Public Types | Public Member Functions | Related Functions | List of all members
cs::int_pair_set Class Reference

Used to store pairs of integers, each of which represents a range of locations in a source file. More...

Public Types

typedef iterator const_iterator
 const iterator over the set contents. More...
 
typedef const int_pairconst_pointer
 const pointer to the type of the set elements. More...
 
typedef const int_pairconst_reference
 const reference to the type of the set elements. More...
 
typedef int_pair_set_iterator iterator
 Iterator over the set contents. More...
 
typedef int_pair key_type
 The type of the set elements. More...
 
typedef int_pairpointer
 Pointer to the type of the set elements. More...
 
typedef int_pairreference
 Reference to the type of the set elements. More...
 
typedef size_t size_type
 Type of set size (cardinality). More...
 
typedef int_pair value_type
 The type of the set elements. More...
 

Public Member Functions

 int_pair_set (const int_pair_set &other)
 Copy constructor. More...
 
 int_pair_set ()
 Construct an empty set. More...
 
 int_pair_set (const std::vector< int_pair_set > &v)
 Constructor: given a std::vector of sets, construct a set that is a multi-union of those sets. More...
 
 int_pair_set (const std::vector< int_pair > &v)
 Construct a set from a std::vector of elements. More...
 
 int_pair_set (set_kind k)
 Construct an empty set of the specified kind. More...
 
bool add (const int_pair &v)
 Add an element to the set. More...
 
std::string as_repr () const
 Get a representation of a set object that includes information useful for debugging.
 
std::string as_string () const
 Get a simple string representation of a set object. More...
 
iterator begin () const
 Get an iterator whose current position is the first element in the set. More...
 
iterator cbegin () const
 Get an iterator whose current position is the first element in the set. More...
 
iterator cend () const
 Get an iterator whose current position is after the end of the set. More...
 
void clear ()
 Remove all elements from the set (that is, make it empty). More...
 
size_type count (const int_pair &e) const
 Count the number of times the specified element appears in a set. More...
 
int_pair_set difference (const int_pair_set &b) const
 Set difference. More...
 
bool empty () const
 Check: is the set empty? More...
 
iterator end () const
 Get an iterator whose current position is after the end of the set. More...
 
size_type erase (const int_pair &v)
 Remove an element from the set. More...
 
const_iterator find (const int_pair &e) const
 Find element e in the set and return an iterator pointing to it if it is found. More...
 
cs_hash_t hash () const
 Get a hash of the set. More...
 
std::pair< iterator, bool > insert (const int_pair &v)
 Insert an element into the set. More...
 
int_pair_set intersect (const int_pair_set &b) const
 Set intersection. More...
 
set_kind kind () const
 Get the kind of a set. More...
 
int_pair_setoperator= (int_pair_set other)
 Assignment operator for int_pair_set. More...
 
size_type size () const
 Get the set cardinality. More...
 
void swap (int_pair_set &other)
 Exchange the contents of this and other. More...
 
point_set to_point_set (sfileinst sfi) const
 Get the point_set associated with an int_pair_set. More...
 
std::vector< int_pairto_vector () const
 Get a std::vector of all the elements in the set. More...
 
int_pair_set union_ (const int_pair_set &b) const
 Set union. More...
 
void union_p (const int_pair_set &b)
 Update a set to the union of itself and another set. More...
 

Related Functions

(Note that these are not member functions.)

bool operator!= (const int_pair_set &__x, const int_pair_set &__y)
 Inequality operator for int_pair_set. More...
 
std::ostream & operator<< (std::ostream &out, const int_pair_set &a)
 Print a representation of a int_pair_set object to the specified stream. More...
 
bool operator== (const int_pair_set &__x, const int_pair_set &__y)
 Equality operator for int_pair_set. More...
 

Detailed Description

Used to store pairs of integers, each of which represents a range of locations in a source file.

Each pair (a, b) in an int_pair_set represents a substring in a source file as follows:

integer represents constraints
a (first) offset from the beginning of the file (0 origin) must be between 0 and 2^24-1
b (second) one less than the length of the substring must be non-negative

The implementation may split a given pair into two or more pairs that represent the same interval.

The following are useful for retrieving int_pair_set values.

Class Methods
point point::charpos()
point_set point_set::to_int_pair_set_in_sfileinst()

Use a int_pair_set_iterator to iterate over a int_pair_set. For example:

for (cs::int_pair_set_iterator it = my_int_pair_set.begin(); !it.at_end(); ++it){
std::cout << "int_pair: " << *it;
}

Member Typedef Documentation

◆ const_iterator

typedef iterator cs::int_pair_set::const_iterator
inherited

const iterator over the set contents.

◆ const_pointer

typedef const int_pair * cs::int_pair_set::const_pointer
inherited

const pointer to the type of the set elements.

◆ const_reference

typedef const int_pair & cs::int_pair_set::const_reference
inherited

const reference to the type of the set elements.

◆ iterator

typedef int_pair_set_iterator cs::int_pair_set::iterator
inherited

Iterator over the set contents.

◆ key_type

typedef int_pair cs::int_pair_set::key_type
inherited

The type of the set elements.

◆ pointer

typedef int_pair * cs::int_pair_set::pointer
inherited

Pointer to the type of the set elements.

◆ reference

typedef int_pair & cs::int_pair_set::reference
inherited

Reference to the type of the set elements.

◆ size_type

typedef size_t cs::int_pair_set::size_type
inherited

Type of set size (cardinality).

◆ value_type

typedef int_pair cs::int_pair_set::value_type
inherited

The type of the set elements.

Constructor & Destructor Documentation

◆ int_pair_set() [1/5]

cs::int_pair_set::int_pair_set ( const int_pair_set other)

Copy constructor.

◆ int_pair_set() [2/5]

cs::int_pair_set::int_pair_set ( )

Construct an empty set.

◆ int_pair_set() [3/5]

cs::int_pair_set::int_pair_set ( set_kind  k)

Construct an empty set of the specified kind.

Parameters
[in]kThe set kind.
Exceptions
result::ERROR_CODESURFER_ONLYif k is set_kind::TRIE, which is only available in CodeSurfer.

◆ int_pair_set() [4/5]

cs::int_pair_set::int_pair_set ( const std::vector< int_pair_set > &  v)

Constructor: given a std::vector of sets, construct a set that is a multi-union of those sets.

◆ int_pair_set() [5/5]

cs::int_pair_set::int_pair_set ( const std::vector< int_pair > &  v)

Construct a set from a std::vector of elements.

Parameters
[in]vThe set elements.

Member Function Documentation

◆ add()

bool cs::int_pair_set::add ( const int_pair v)
inlineinherited

Add an element to the set.

Parameters
[in]vThe element to add.
Returns
true if v was not already present in the set, false if it was already present.

◆ as_string()

std::string cs::int_pair_set::as_string ( ) const
inlineinherited

Get a simple string representation of a set object.

◆ begin()

iterator cs::int_pair_set::begin ( ) const
inlineinherited

Get an iterator whose current position is the first element in the set.

Returns
The iterator.

◆ cbegin()

iterator cs::int_pair_set::cbegin ( ) const
inlineinherited

Get an iterator whose current position is the first element in the set.

Returns
The iterator.

◆ cend()

iterator cs::int_pair_set::cend ( ) const
inlineinherited

Get an iterator whose current position is after the end of the set.

Returns
The iterator.

◆ clear()

void cs::int_pair_set::clear ( )
inlineinherited

Remove all elements from the set (that is, make it empty).

Returns
void

◆ count()

size_type cs::int_pair_set::count ( const int_pair e) const
inlineinherited

Count the number of times the specified element appears in a set.

Parameters
[in]eThe element of interest.
Returns
1 if e is present in the set, 0 otherwise.

◆ difference()

int_pair_set cs::int_pair_set::difference ( const int_pair_set b) const
inlineinherited

Set difference.

Parameters
[in]bThe set to subtract from this.
Returns
A set containing this - b.

The returned set contains the elements in this that are not in b.

◆ empty()

bool cs::int_pair_set::empty ( ) const
inlineinherited

Check: is the set empty?

Returns
true if the set is empty, false otherwise.

◆ end()

iterator cs::int_pair_set::end ( ) const
inlineinherited

Get an iterator whose current position is after the end of the set.

Returns
The iterator.

◆ erase()

size_type cs::int_pair_set::erase ( const int_pair v)
inlineinherited

Remove an element from the set.

Parameters
[in]vThe element to remove.
Returns
The number of elements deleted:
  • 1 if v was present in the set.
  • 0 if v was not present in the set.

◆ find()

const_iterator cs::int_pair_set::find ( const int_pair e) const
inlineinherited

Find element e in the set and return an iterator pointing to it if it is found.

Returns
An iterator whose current position is:
  • the set element matching e if e is present in the set,
  • after the end of the set otherwise.

◆ hash()

cs_hash_t cs::int_pair_set::hash ( ) const
inlineinherited

Get a hash of the set.

Returns
The hash value for the set.

◆ insert()

std::pair<iterator, bool> cs::int_pair_set::insert ( const int_pair v)
inlineinherited

Insert an element into the set.

Parameters
[in]vThe element to add.
Returns
A pair (itr,b), where
  • itr points to the newly inserted element (or the element whose key is equivalent, if it was already present).
  • b is true if v was not already present in the set, false if it was already present.

◆ intersect()

int_pair_set cs::int_pair_set::intersect ( const int_pair_set b) const
inlineinherited

Set intersection.

Parameters
[in]bThe other operand for the intersection operation.
Returns
A set containing this INTERSECT b.

The returned set contains the elements that are in both this and b.

◆ kind()

set_kind cs::int_pair_set::kind ( ) const
inlineinherited

Get the kind of a set.

Returns
The set kind (cs::set_kind).
Exceptions
result::ELEMENT_NOT_PRESENTif the set was constructed with the default constructor and no elements have been added yet.

◆ operator=()

int_pair_set& cs::int_pair_set::operator= ( int_pair_set  other)

Assignment operator for int_pair_set.

◆ size()

size_type cs::int_pair_set::size ( ) const
inlineinherited

Get the set cardinality.

Returns
The number of elements in the set.

◆ swap()

void cs::int_pair_set::swap ( int_pair_set other)
inlineinherited

Exchange the contents of this and other.

◆ to_point_set()

point_set cs::int_pair_set::to_point_set ( sfileinst  sfi) const
inherited

Get the point_set associated with an int_pair_set.

Parameters
[in]sfiThe source file instance for which the int_pair_set contains file positions.
Returns
A new point_set containing the points corresponding to the locations given by this in the file identified by sfi.

◆ to_vector()

std::vector<int_pair > cs::int_pair_set::to_vector ( ) const
inlineinherited

Get a std::vector of all the elements in the set.

Returns
A std::vector containing all the elements in the set.

◆ union_()

int_pair_set cs::int_pair_set::union_ ( const int_pair_set b) const
inlineinherited

Set union.

Parameters
[in]bThe other operand for the union operation.
Returns
A set containing this UNION b.

The returned set contains the elements that are in this, b, or both.

◆ union_p()

void cs::int_pair_set::union_p ( const int_pair_set b)
inlineinherited

Update a set to the union of itself and another set.

Parameters
[in]bThe set whose elements are to be added.
Returns
void

this is updated to contain this UNION b.

Friends And Related Function Documentation

◆ operator!=()

bool operator!= ( const int_pair_set __x,
const int_pair_set __y 
)
related

Inequality operator for int_pair_set.

Parameters
[in]__xThe set to compare.
[in]__yThe set to compare against.
Returns
false if __x equal to __y according to operator==(), true otherwise.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  out,
const int_pair_set a 
)
related

Print a representation of a int_pair_set object to the specified stream.

Parameters
[in]outThe stream to print to.
[in]aThe int_pair_set object to print.
Returns
void

◆ operator==()

bool operator== ( const int_pair_set __x,
const int_pair_set __y 
)
related

Equality operator for int_pair_set.

Parameters
[in]__xThe set to compare.
[in]__yThe set to compare against.
Returns
true if __x equal to __y, false otherwise.

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