returns a sorted array of nested classes and interfaces
966668
public GroovyClassDoc[] innerClasses() {
        Collections.sort(nested);
        return nested.toArray(new GroovyClassDoc[nested.size()]);
    }
237782
public JClass []getInterfaces()
  {
    lazyLoad();
    
    JClass []interfaces = new JClass[_interfaces.size()];

    for (int i = 0; i < _interfaces.size(); i++) {
      String name = _interfaces.get(i);
      name = name.replace('/', '.');
      
      interfaces[i] = getClassLoader().forName(name);
    }
    
    return interfaces;
  }
820333
def classorder(self,classes):
        """"""
        return [ classid for classid, classitem in sorted( ((classid, classitem) for classid, classitem in classes.items() if 'seqnr' in classitem) , key=lambda pair: pair[1]['seqnr'] )] + \
               [ classid for classid, classitem in sorted( ((classid, classitem) for classid, classitem in classes.items() if 'seqnr' not in classitem) , key=lambda pair: pair[1]['label'] if 'label' in pair[1] else pair[1]['id']) ]
105871
def get_subclass_tree(cls, ensure_unique=True):
    """"""
    subclasses = []
    # cls.__subclasses__() fails on classes inheriting from type
    for subcls in type.__subclasses__(cls):
        subclasses.append(subcls)
        subclasses.extend(get_subclass_tree(subcls, ensure_unique))
    return list(set(subclasses)) if ensure_unique else subclasses
608654
public function getInterfaces()
    {
        $interfaces     = parent::getInterfaces();
        $moufRefClasses = array();
        foreach ($interfaces as $interface) {
            $moufRefClasses[] = new self($interface->getName());
        }
        
        return $moufRefClasses;
    }
936433
public static Class[] getSuperTypes(Class from) {
        ArrayList<Class> superclasses = new ArrayList<Class>();

        collectInterfaces( from, superclasses );
        while ( !from.equals( Object.class ) && !from.isInterface() ) {
            superclasses.add( from.getSuperclass() );
            from = from.getSuperclass();
            collectInterfaces( from, superclasses );
        }

        final Class[] classes = new Class[superclasses.size()];
        superclasses.toArray(classes);
        return classes;
    }
320195
def ArrayOf(klass, fixed_length=None, prototype=None):
    """"""
    global _array_of_map
    global _array_of_classes, _sequence_of_classes

    # check the parameters for consistency
    if issubclass(klass, Atomic):
        if prototype is None:
            pass
        elif not klass.is_valid(prototype):
            raise ValueError("prototype %r not valid for %s" % (prototype, klass.__name__))
    else:
        if prototype is None:
            ### TODO This should be an error, a prototype should always be
            ### required for non-atomic types, even if it's only klass()
            ### for a default object which will be deep copied
            pass
        elif not isinstance(prototype, klass):
            raise ValueError("prototype %r not valid for %s" % (prototype, klass.__name__))

    # build a signature of the parameters
    array_signature = (klass, fixed_length, prototype)

    # if this has already been built, return the cached one
    if array_signature in _array_of_map:
        return _array_of_map[array_signature]

    # no ArrayOf(ArrayOf(...)) allowed
    if klass in _array_of_classes:
        raise TypeError("nested arrays disallowed")
    # no ArrayOf(SequenceOf(...)) allowed
    if klass in _sequence_of_classes:
        raise TypeError("arrays of SequenceOf disallowed")

    # define a generic class for arrays
    @bacpypes_debugging
    class ArrayOf(Array):

        subtype = None
        fixed_length = None
        prototype = None

        def __init__(self, value=None):
            if value is None:
                self.value = [0]
                if self.fixed_length is not None:
                    self.fix_length(self.fixed_length)

            elif isinstance(value, list):
                if (self.fixed_length is not None) and (len(value) != self.fixed_length):
                    raise ValueError("invalid array length")

                self.value = [len(value)]
                self.value.extend(value)
            else:
                raise TypeError("invalid constructor datatype")

        def fix_length(self, new_length):
            if len(self.value) > new_length + 1:
                # trim off the excess
                del self.value[new_length + 1:]
            elif len(self.value) < new_length + 1:
                # how many do we need
                element_count = new_length - len(self.value) + 1

                # extend or append
                if issubclass(self.subtype, Atomic):
                    if self.prototype is None:
                        extend_value = self.subtype().value
                    else:
                        extend_value = self.prototype
                    self.value.extend( [extend_value] * element_count )
                else:
                    for i in range(element_count):
                        if self.prototype is None:
                            append_value = self.subtype()
                        else:
                            append_value = _deepcopy(self.prototype)
                        self.value.append(append_value)

            self.value[0] = new_length

        def append(self, value):
            if self.fixed_length is not None:
                raise TypeError("fixed length array")

            if issubclass(self.subtype, Atomic):
                pass
            elif issubclass(self.subtype, AnyAtomic) and not isinstance(value, Atomic):
                raise TypeError("instance of an atomic type required")
            elif not isinstance(value, self.subtype):
                raise TypeError("%s value required" % (self.subtype.__name__,))

            self.value.append(value)
            self.value[0] = len(self.value) - 1

        def __len__(self):
            return self.value[0]

        def __getitem__(self, item):
            # no wrapping index
            if (item < 0) or (item > self.value[0]):
                raise IndexError("index out of range")

            return self.value[item]

        def __setitem__(self, item, value):
            # no wrapping index
            if (item < 0) or (item > self.value[0]):
                raise IndexError("index out of range")

            # special length handling for index 0
            if item == 0:
                if (self.fixed_length is not None):
                    if (value != self.value[0]):
                        raise TypeError("fixed length array")
                    return

                self.fix_length(value)
            else:
                self.value[item] = value

        def __delitem__(self, item):
            if self.fixed_length is not None:
                raise TypeError("fixed length array")

            # no wrapping index
            if (item < 1) or (item > self.value[0]):
                raise IndexError("index out of range")

            # delete the item and update the length
            del self.value[item]
            self.value[0] -= 1

        def __iter__(self):
            return iter(self.value[1:])

        def index(self, value):
            # only search through values
            for i in range(1, self.value[0] + 1):
                if value == self.value[i]:
                    return i

            # not found
            raise ValueError("%r not in array" % (value,))

        def remove(self, item):
            if self.fixed_length is not None:
                raise TypeError("fixed length array")

            # find the index of the item and delete it
            indx = self.index(item)
            self.__delitem__(indx)

        def encode(self, taglist):
            if _debug: ArrayOf._debug("(%r)encode %r", self.__class__.__name__, taglist)

            for value in self.value[1:]:
                if issubclass(self.subtype, (Atomic, AnyAtomic)):
                    # a helper cooperates between the atomic value and the tag
                    helper = self.subtype(value)

                    # build a tag and encode the data into it
                    tag = Tag()
                    helper.encode(tag)

                    # now encode the tag
                    taglist.append(tag)
                elif isinstance(value, self.subtype):
                    # it must have its own encoder
                    value.encode(taglist)
                else:
                    raise TypeError("%s must be a %s" % (value, self.subtype.__name__))

        def decode(self, taglist):
            if _debug: ArrayOf._debug("(%r)decode %r", self.__class__.__name__, taglist)

            # start with an empty array
            new_value = []

            while len(taglist) != 0:
                tag = taglist.Peek()
                if tag.tagClass == Tag.closingTagClass:
                    break

                if issubclass(self.subtype, (Atomic, AnyAtomic)):
                    if _debug: ArrayOf._debug("    - building helper: %r %r", self.subtype, tag)
                    taglist.Pop()

                    # a helper cooperates between the atomic value and the tag
                    helper = self.subtype(tag)

                    # save the value
                    new_value.append(helper.value)
                else:
                    if _debug: ArrayOf._debug("    - building value: %r", self.subtype)
                    # build an element
                    value = self.subtype()

                    # let it decode itself
                    value.decode(taglist)

                    # save what was built
                    new_value.append(value)

            # check the length
            if self.fixed_length is not None:
                if self.fixed_length != len(new_value):
                    raise ValueError("invalid array length")

            # update the length
            self.value = [len(new_value)] + new_value

        def encode_item(self, item, taglist):
            if _debug: ArrayOf._debug("(%r)encode_item %r %r", self.__class__.__name__, item, taglist)

            if item == 0:
                # a helper cooperates between the atomic value and the tag
                helper = Unsigned(self.value[0])

                # build a tag and encode the data into it
                tag = Tag()
                helper.encode(tag)

                # now encode the tag
                taglist.append(tag)
            else:
                value = self.value[item]

                if issubclass(self.subtype, (Atomic, AnyAtomic)):
                    # a helper cooperates between the atomic value and the tag
                    helper = self.subtype(self.value[item])

                    # build a tag and encode the data into it
                    tag = Tag()
                    helper.encode(tag)

                    # now encode the tag
                    taglist.append(tag)
                elif isinstance(value, self.subtype):
                    # it must have its own encoder
                    value.encode(taglist)
                else:
                    raise TypeError("%s must be a %s" % (value, self.subtype.__name__))

        def decode_item(self, item, taglist):
            if _debug: ArrayOf._debug("(%r)decode_item %r %r", self.__class__.__name__, item, taglist)

            if item == 0:
                # a helper cooperates between the atomic value and the tag
                helper = Unsigned(taglist.Pop())

                # save the value
                self.value = helper.value
            elif issubclass(self.subtype, (Atomic, AnyAtomic)):
                if _debug: ArrayOf._debug("    - building helper: %r", self.subtype)

                # a helper cooperates between the atomic value and the tag
                helper = self.subtype(taglist.Pop())

                # save the value
                self.value = helper.value
            else:
                if _debug: ArrayOf._debug("    - building value: %r", self.subtype)
                # build an element
                value = self.subtype()

                # let it decode itself
                value.decode(taglist)

                # save what was built
                self.value = value

        def debug_contents(self, indent=1, file=sys.stdout, _ids=None):
            try:
                value_list = enumerate(self.value)
            except TypeError:
                file.write("%s(non-sequence) %r\n" % ("    " * indent, self.value))
                return

            for i, value in value_list:
                if i == 0:
                    file.write("%slength = %d\n" % ("    " * indent, value))
                elif issubclass(self.subtype, (Atomic, AnyAtomic)):
                    file.write("%s[%d] = %r\n" % ("    " * indent, i, value))
                elif isinstance(value, self.subtype):
                    file.write("%s[%d]\n" % ("    " * indent, i))
                    value.debug_contents(indent+1, file, _ids)
                else:
                    file.write("%s%s must be a %s" % ("    " * indent, value, self.subtype.__name__))

        def dict_contents(self, use_dict=None, as_class=dict):
            # return arrays as arrays
            mapped_value = []

            for value in self.value:
                if issubclass(self.subtype, Atomic):
                    mapped_value.append(value)              ### ambiguous
                elif issubclass(self.subtype, AnyAtomic):
                    mapped_value.append(value.value)        ### ambiguous
                elif isinstance(value, self.subtype):
                    mapped_value.append(value.dict_contents(as_class=as_class))

            # return what we built
            return mapped_value

    # constrain it to a list of a specific type of item
    setattr(ArrayOf, 'subtype', klass)
    setattr(ArrayOf, 'fixed_length', fixed_length)
    setattr(ArrayOf, 'prototype', prototype)

    # update the name
    ArrayOf.__name__ = 'ArrayOf' + klass.__name__

    # cache this type
    _array_of_map[array_signature] = ArrayOf
    _array_of_classes[ArrayOf] = 1

    # return this new type
    return ArrayOf
594784
private function getClassParentsAndInterfaces()
    {
        $phpcsFile = $this->phpcsFile;
        $tokens = $phpcsFile->getTokens();
        $nsStart = $phpcsFile->findNext(array(T_NAMESPACE), 0);
        $class = '';

        // Set the default return value.
        $this->parentsAndInterfaces = false;

        // Build the namespace.
        if (false !== $nsStart) {
            $nsEnd = $phpcsFile->findNext(array(T_SEMICOLON), $nsStart + 2);
            for ($i = $nsStart + 2; $i < $nsEnd; $i++) {
                $class .= $tokens[$i]['content'];
            }
            $class .= '\\';
        } else {
            $nsEnd = 0;
        }

        // Find the class/interface declaration.
        $classPtr = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE), $nsEnd);

        if (false !== $classPtr) {
            $class .= $phpcsFile->getDeclarationName($classPtr);

            if (\class_exists($class) || \interface_exists($class)) {
                $this->parentsAndInterfaces = \array_merge(\class_parents($class), \class_implements($class));
            }
        }

        return $this->parentsAndInterfaces;
    }
1209593
public static Class[] getImplementorClasses( Class interfaceType )
    {
        String interfaceName = interfaceType.getName();
        ArrayList/*< Class >*/ classes = new ArrayList/*< Class >*/();
        ClassLoader classLoader = getClassLoader();
        
        try
        {
            Enumeration e = classLoader.getResources( "META-INF/services/" + interfaceName );
            
            while ( e.hasMoreElements() )
            {
                URL url = ( URL ) e.nextElement();
                
                if ( _log.isTraceEnabled() )
                {
                    _log.trace( "Found implementor entry for interface " + interfaceName + " at " + url );
                }
                
                InputStream is = null;
                String className = null;
                
                try
                {
                    is = url.openStream();
                    BufferedReader reader = new BufferedReader( new InputStreamReader( is ) );
                    className = reader.readLine().trim();
                    Class implementorClass = loadImplementorClass( className, interfaceType, classLoader );
                    if ( implementorClass != null ) classes.add( implementorClass );
                }
                catch ( IOException ioe )
                {
                    _log.error( "Could not read implementor class entry at + " + url );
                }
                finally
                {
                    if ( is != null ) is.close();
                }
            }
        }
        catch ( IOException e )
        {
            _log.error( "Could not discover implementors for " + interfaceName, e );
        }
        
        return ( Class[] ) classes.toArray( new Class[0] );
    }
32287
private Class[] getInterfaces(Class clazz) {
        Class superClazz = clazz;
        Class[] interfaces = clazz.getInterfaces();

        // clazz can be an interface itself and when getInterfaces()
        // is called on an interface it returns only the extending
        // interfaces, not the interface itself.
        if (clazz.isInterface()) {
            Class[] tempInterfaces = new Class[interfaces.length + 1];
            tempInterfaces[0] = clazz;

            System.arraycopy(interfaces, 0, tempInterfaces, 1, interfaces.length);
            interfaces = tempInterfaces;
        }

        // add all interfaces implemented by superclasses to the interfaces array
        while ((superClazz = superClazz.getSuperclass()) != null) {
            Class[] superInterfaces = superClazz.getInterfaces();
            Class[] combInterfaces = new Class[interfaces.length + superInterfaces.length];
            System.arraycopy(interfaces, 0, combInterfaces, 0, interfaces.length);
            System.arraycopy(superInterfaces, 0, combInterfaces, interfaces.length, superInterfaces.length);
            interfaces = combInterfaces;
        }

        /**
         * Must remove duplicate interfaces before calling Proxy.getProxyClass().
         * Duplicates can occur if a subclass re-declares that it implements
         * the same interface as one of its ancestor classes.
         **/
        HashMap unique = new HashMap();
        for (int i = 0; i < interfaces.length; i++) {
            unique.put(interfaces[i].getName(), interfaces[i]);
        }
        /* Add the OJBProxy interface as well */
        unique.put(OJBProxy.class.getName(), OJBProxy.class);

        interfaces = (Class[])unique.values().toArray(new Class[unique.size()]);

        return interfaces;
    }
627466
private static Class<?>[] getTypes(Object... objects) {
        if (objects == null) {
            return new Class[0];
        }

        Class<?>[] result = new Class[objects.length];

        for (int i = 0; i < objects.length; i++) {
            Object value = objects[i];
            result[i] = value == null ? NULL.class : value.getClass();
        }

        return result;
    }
987081
private IntIntPair[] sortEdges(int[] dindex) {
    IntIntPair[] edgesort = new IntIntPair[shared.layout.edges.size()];
    int e = 0;
    for(Layout.Edge edge : shared.layout.edges) {
      int i1 = dindex[edge.dim1], i2 = dindex[edge.dim2];
      edgesort[e] = new IntIntPair(Math.min(i1, i2), e);
      e++;
    }
    Arrays.sort(edgesort);
    return edgesort;
  }
286422
public function findMultiple($classes = [], $interfaces = [], $traits = []) {
        $this->init();

        $classes    = $this->normalizeArray($classes);
        $interfaces = $this->normalizeArray($interfaces);
        $traits     = $this->normalizeArray($traits);

        $foundClasses = [];

        if ($classes !== false) {
            foreach ($classes as $class) {
                $foundClasses = array_merge($foundClasses, $this->findExtends($class));
            }
        }

        if ($interfaces !== false) {
            foreach ($interfaces as $interface) {
                $foundClasses = array_merge($foundClasses, $this->findImplements($interface));
            }
        }

        if ($traits !== false) {
            foreach ($traits as $trait) {
                $foundClasses = array_merge($foundClasses, $this->findTraitUse($trait));
            }
        }

        return $this->arrayUniqueObject($foundClasses);
    }
81053
static Class<?>[] getAncestors(Class<?> clazz) {
        Set<Class<?>> classes = new HashSet<Class<?>>();
        while (clazz != null) {
            classes.add(clazz);
            if (clazz.getSuperclass() != null) {
                classes.add(clazz.getSuperclass());
            }
            classes.addAll(Arrays.asList(clazz.getInterfaces()));
            for (Class<?> interfaze : clazz.getInterfaces()) {
                classes.addAll(Arrays.asList(getAncestors(interfaze)));
            }

            clazz = clazz.getSuperclass();
        }

        return classes.toArray(new Class<?>[classes.size()]);
    }
39004
def registered_types
      list = []

      registered_types_internal.each_pair do |type, ary|
        list << {type: type, class: ary[0], unpacker: ary[2]}
      end

      list.sort{|a, b| a[:type] <=> b[:type] }
    end
1264086
private static Class<?>[] getTypes(Object[] arguments) {
        Class<?>[] classes = new Class<?>[arguments.length];
        for (int i = 0; i < arguments.length; i++) {
            classes[i] = getType(arguments[i]);
        }
        return classes;
    }
190244
public static void getAllInterfaces(Class<?> classObject, ArrayList<Type> interfaces) {
        Type[] superInterfaces = classObject.getGenericInterfaces();
        interfaces.addAll((Arrays.asList(superInterfaces)));

        // for cases where the extended class is defined with a Generic.
        Type tgs = classObject.getGenericSuperclass();
        if (tgs != null) {
            if ((tgs) instanceof ParameterizedType) {
                interfaces.add(tgs);
            }
        }

        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "updated interfaces to: " + interfaces);
        }

        Class<?> superClass = classObject.getSuperclass();
        if (superClass != null) {
            getAllInterfaces(superClass, interfaces);
        }
    }