Iterate segments based on type

        Args:
            seg_type: type of segment e.g. SEG_CODE

        Returns:
            iterator of `Segment` objects. if seg_type is None , returns all segments
            otherwise returns only the relevant ones
435660
def segments(seg_type=None):
    

    for index in xrange(idaapi.get_segm_qty()):
        seg = Segment(index=index)
        if (seg_type is None) or (seg.type == seg_type):
            yield Segment(index=index)
1121772
def simple_seg(hans):
    """"""
    assert not isinstance(hans, bytes_type), \
        'must be unicode string or [unicode, ...] list'

    if isinstance(hans, text_type):
        return _seg(hans)
    else:
        hans = list(hans)
        if len(hans) == 1:
            return simple_seg(hans[0])
        return list(chain(*[simple_seg(x) for x in hans]))
1232330
def find_all(self, node_type):
        
        for child in self.iter_child_nodes():
            if isinstance(child, node_type):
                yield child
            for result in child.find_all(node_type):
                yield result
6349
def get_all_conversion_chains_from_type(self, from_type: Type[Any]) \
            -> Tuple[List[Converter], List[Converter], List[Converter]]:
        
        return self.get_all_conversion_chains(from_type=from_type)
620173
def in_segmentlist(column, segmentlist):
    
    segmentlist = type(segmentlist)(segmentlist).coalesce()
    idx = column.argsort()
    contains = numpy.zeros(column.shape[0], dtype=bool)
    j = 0
    try:
        segstart, segend = segmentlist[j]
    except IndexError:  # no segments, return all False
        return contains
    i = 0
    while i < contains.shape[0]:
        # extract time for this index
        x = idx[i]  # <- index in original column
        time = column[x]
        # if before start, move to next value
        if time < segstart:
            i += 1
            continue
        # if after end, find the next segment and check value again
        if time >= segend:
            j += 1
            try:
                segstart, segend = segmentlist[j]
                continue
            except IndexError:
                break
        # otherwise value must be in this segment
        contains[x] = True
        i += 1
    return contains
1028800
def segments(self):
        '''
        

        '''
        return [Segment(self.AB),
                Segment(self.BC),
                Segment(self.AC)]
292422
function buildSegmentRows(segments) {
		var rowCnt = getRowCnt();
		var segmentRows = [];
		var segmentI;
		var segment;
		var rowI;

		// group segments by row
		for (segmentI=0; segmentI<segments.length; segmentI++) {
			segment = segments[segmentI];
			rowI = segment.row;
			if (segment.element) { // was rendered?
				if (segmentRows[rowI]) {
					// already other segments. append to array
					segmentRows[rowI].push(segment);
				}
				else {
					// first segment in row. create new array
					segmentRows[rowI] = [ segment ];
				}
			}
		}

		// sort each row
		for (rowI=0; rowI<rowCnt; rowI++) {
			segmentRows[rowI] = sortSegmentRow(
				segmentRows[rowI] || [] // guarantee an array, even if no segments
			);
		}

		return segmentRows;
	}
853820
def user_segment(self):
        
        if self.api and self.user_segment_id:
            return self.api._get_user_segment(self.user_segment_id)
748782
def _get_types(type_):
    

    return list(
        itertools.chain.from_iterable(
            map(lambda x: TYPE_MAPPINGS[x].get(type_, []), TYPE_MAPPINGS)
        )
    )
379749
def tokens(self):
        
        for subsegment_or_token in self:
            if isinstance(subsegment_or_token, Segment):
                subsegment = subsegment_or_token
                for token in subsegment.tokens():
                    yield token
            else:
                token = subsegment_or_token
                yield token
819938
@Pure
	public Iterable<IntegerSegment> toSegmentIterable() {
		return new Iterable<IntegerSegment>() {
			@Override
			public Iterator<IntegerSegment> iterator() {
				return new SegmentIterator();
			}
		};
	}
525813
def dt(self, start_node=None):
        
        if start_node is None:
            return self.root2tree(start_node=start_node)

        elem_id = start_node
        if elem_id not in self.elem_dict:
            return []

        elem = self.elem_dict[elem_id]
        elem_type = elem['element_type']

        assert elem_type in ('segment', 'group')

        if elem_type == 'segment':
            return self.segment2tree(
                elem_id, elem, elem_type, start_node=start_node)

        else:
            return self.group2tree(
                elem_id, elem, elem_type, start_node=start_node)
1288577
def to_segmentlistdict(self):
		
		d = segments.segmentlistdict()
		for entry in self:
			d |= entry.segmentlistdict
		return d
572909
def _type_check_pointers(utype):
    
    result = []
    for mname, member in utype.members.items():
        if ("pointer" in member.modifiers and member.D > 0 and
            (member.default is None or "null" not in member.default)):
            result.append(member)

    return result
1100250
def SegmentCollection(mode="agg-fast", *args, **kwargs):
    

    if mode == "raw":
        return RawSegmentCollection(*args, **kwargs)
    return AggSegmentCollection(*args, **kwargs)
198928
def alloc_seg(self, net_id):
        
        segmentation_id = self.service_segs.allocate_segmentation_id(
            net_id, source=fw_const.FW_CONST)
        return segmentation_id
327933
def _allocate_specified_segment(self, session, seg_id, source):
        
        try:
            with session.begin(subtransactions=True):
                alloc = (session.query(self.model).filter_by(
                    segmentation_id=seg_id).first())
                if alloc:
                    if alloc.allocated:
                        # Segment already allocated
                        return
                    else:
                        # Segment not allocated
                        count = (session.query(self.model).
                                 filter_by(allocated=False,
                                           segmentation_id=seg_id).update(
                                               {"allocated": True}))
                        if count:
                            return alloc

                # Segment to create or already allocated
                alloc = self.model(segmentation_id=seg_id,
                                   allocated=True, source=source)
                session.add(alloc)

        except db_exc.DBDuplicateEntry:
            # Segment already allocated (insert failure)
            alloc = None

        return alloc