class int_pair_set_iterator

Iterator over the (int, int) elements of a int_pair_set .

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

for e in my_int_pair_set:
    print('int_pair: ', e)

int_pair_set_iterator Details

class cs.int_pair_set_iterator

Iterator over the (int, int) elements of a int_pair_set .

__eq__(other)

Iterator equality.

Parameters:other (int_pair_set_iterator) –
Return type:bool
Returns:True if and only if self and other are at the same position. Behavior is undefined if self and other are not iterating over the same collection.
>>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp'))
>>> proc = next(p for p in cu.procedures() if p.name()=='foo')
>>> call_pt = next(pt for pt in proc.points() if pt.get_kind() == point_kind.CALL_SITE)
>>> call_pt_locs = call_pt.charpos()[1]
>>> print(call_pt, call_pt_locs)
[call-site] bar(int, void *, int) {(571, 3), (595, 0)}
>>> ips_iterA = iter(call_pt_locs)
>>> ips_iterB = iter(call_pt_locs)
>>> ips_iterA == ips_iterB
True
>>> for offset,sslen in ips_iterA:
...       if sslen<100:
...           break
...
>>> ips_iterA == ips_iterB
False
__iter__()

Get the iterator object.

Return type:int_pair_set_iterator
Returns:self.
>>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp'))
>>> proc = next(p for p in cu.procedures() if p.name()=='foo')
>>> call_pt = next(pt for pt in proc.points() if pt.get_kind() == point_kind.CALL_SITE)
>>> call_pt_locs = call_pt.charpos()[1]
>>> for pr in iter(call_pt_locs): # iteration managed by cs.int_pair_set_iterator.__iter__ and cs.int_pair_set_iterator.__next__
...     print(pr)
...
(571, 3)
(595, 0)
__ne__(other)

Iterator inequality.

Parameters:other (int_pair_set_iterator) – The iterator to compare against.
Return type:bool
Returns:False if and only if self and other are at the same position. Behavior is undefined if self and other are not iterating over the same collection.
>>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp'))
>>> proc = next(p for p in cu.procedures() if p.name()=='foo')
>>> call_pt = next(pt for pt in proc.points() if pt.get_kind() == point_kind.CALL_SITE)
>>> call_pt_locs = call_pt.charpos()[1]
>>> print(call_pt, call_pt_locs)
[call-site] bar(int, void *, int) {(571, 3), (595, 0)}
>>> ips_iterA = iter(call_pt_locs)
>>> ips_iterB = iter(call_pt_locs)
>>> ips_iterA != ips_iterB
False
>>> for offset,sslen in ips_iterA:
...       if sslen<100:
...           break
...
>>> ips_iterA != ips_iterB
True
__next__()

Iterator dereference operator.

Return type:(int, int)
Returns:The element at the current iterator position.
Raises:StopIteration
  • Side effects: Modifies self.

The typical use is implicit:

>>> for item in myiter:
...   (do something to item)
>>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp'))
>>> proc = next(p for p in cu.procedures() if p.name()=='foo')
>>> call_pt = next(pt for pt in proc.points() if pt.get_kind() == point_kind.CALL_SITE)
>>> call_pt_locs = call_pt.charpos()[1]
>>> for pr in iter(call_pt_locs): # iteration managed by cs.int_pair_set_iterator.__iter__ and cs.int_pair_set_iterator.__next__
...     print(pr)
...
(571, 3)
(595, 0)
__repr__()

Get a representation of the iterator that includes information useful for debugging.

Return type:str
Returns:The string representation.
>>> v0 = int_pair_set()
>>> v1 = iter(v0)
>>> repr(v1)
'<cs.int_pair_set_iterator begin>'
__str__()

Get a simple string representation of the iterator.

Return type:str
Returns:The string representation.
>>> v0 = int_pair_set()
>>> v1 = iter(v0)
>>> str(v1)
'<cs.int_pair_set_iterator begin>'
at_end()

Check: is the iterator at the end of the structure?

Return type:bool
Returns:True if the iterator is at the end of the structure (there are no more elements to iterate over), False otherwise.
>>> v0 = int_pair_set()
>>> v1 = iter(v0)
>>> v1.at_end()
True