Convert to an array.
This will include any protected or private properties as well as public.
Normally this shouldn't be an issue as struct classes are usually
intended to have all members public.
13145
public function toArray()
    {
        $ret = [ ];
        foreach ($this as $key => $value) {
            $ret[ $key ] = $value;
        }
        return $ret;
    }
45880
def convert_to_struct(value):
    
    direct_converts = [dict, OrderedDict, UserDict]
    if type(value) in direct_converts:
        # Convert dict-like things to Struct
        value = Struct(value)
    elif isinstance(value, list):
        # Process list elements
        value = [convert_to_struct(z) for z in value]

    # Done
    return value
797252
def to_struct(cls, name=None):
        
        if name is None:
            name = cls.__name__
        basic_attrs = dict([(attr_name, value)
                            for attr_name, value in cls.get_attrs()
                            if isinstance(value, Column)])
        if not basic_attrs:
            return None
        src = 'struct {0} {{'.format(name)
        for attr_name, value in basic_attrs.items():
            src += '{0} {1};'.format(value.type.typename, attr_name)
        src += '};'
        if ROOT.gROOT.ProcessLine(src) != 0:
            return None
        return getattr(ROOT, name, None)
1253126
function to_array(obj) { var result, i
        result = []
        obj    = Object(obj)
        for (i = size(obj); i--;)
            if (i in obj)  result[i] = obj[i]

        return result
    }
1196697
public function toJson() {
    	$result = array();
    	$result['name'] = $this->getName();
    	$result['hasDefault'] = $this->isDefaultValueAvailable();
    	try {
    		if ($result['hasDefault']) {
    			// In some cases, the call to getDefaultValue can log NOTICES
    			// in particular if an undefined constant is used as default value.
    			ob_start();
    			if ($this->isDefaultValueConstant() && !defined($this->getDefaultValueConstantName())) {
    			    throw new \Exception('Constant "'.$this->getDefaultValueConstantName().'" does not exist.');
                }
    			$result['default'] = $this->getDefaultValue();
    			$possibleError = ob_get_clean();
    			if ($possibleError) {
    				throw new \Exception($possibleError);
    			}
    		}
    		$result['isArray'] = $this->isArray();
    		
    		// Let's export only the type if we are in a constructor... in order to save time.
    		if ($this->getDeclaringFunction()->isConstructor()) {
    			// TODO: is there a need to instanciate a  MoufPropertyDescriptor?
    			$moufPropertyDescriptor = new MoufPropertyDescriptor($this);
    
    			$result['comment'] = $moufPropertyDescriptor->getDocCommentWithoutAnnotations();
    
    	    	$types = $moufPropertyDescriptor->getTypes();
	    		$result['types'] = $types->toJson();
	    	 
	    		if ($types->getWarningMessage()) {
	    			$result['classinerror'] = $types->getWarningMessage();
	    		}
    			
    			/*if ($moufPropertyDescriptor->isAssociativeArray()) {
    				$result['keytype'] = $moufPropertyDescriptor->getKeyType();
    			}
    			if ($moufPropertyDescriptor->isArray()) {
    				$result['subtype'] = $moufPropertyDescriptor->getSubType();
    			}*/
    		}
    	} catch (\Exception $e) {
    		$result['classinerror'] = $e->getMessage();
    	}
    
    	return $result;
    }
1347114
public static Object[] toArray(List<?> list) {
	Iterator<?> it = list.iterator();
	Class clazz = null;
	while (it.hasNext()) {
	    Object v = it.next();
	    if (v == null) continue;
	    if (clazz == null) clazz = v.getClass();
	    else if (clazz != v.getClass()) return list.toArray();
	}
	if (clazz == Object.class || clazz == null) return list.toArray();

	Object arr = java.lang.reflect.Array.newInstance(clazz, list.size());
	return list.toArray((Object[]) arr);
    }
153685
def from_value(value):
        
        value = ArrayConverter.to_nullable_array(value)
        if value != None:
            return AnyValueArray(value)
        return AnyValueArray()
1288031
private Object convertListToArray(List<?> rawValues, ExtendedAttributeDefinition attrDef, EvaluationContext context, boolean ignoreWarnings) throws ConfigEvaluatorException {
        // The implementation of this method is similar to convertListToVector,
        // but this method needs to handle primitive array types.  This could
        // be implemented by calling convertListToVector first, but that would
        // require boxing/unboxing the primitive values.  To avoid that, the
        // logic from the convertListToVector and convertObjectToSingleValue
        // methods is inlined for the primitive array types.

        int size = rawValues.size();
        int type = attrDef.getType();
        int i = 0;
        if (type == AttributeDefinition.BOOLEAN) {
            boolean[] retVal = new boolean[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Boolean.parseBoolean(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.BYTE) {
            byte[] retVal = new byte[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Byte.parseByte(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.CHARACTER) {
            char[] retVal = new char[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = value.charAt(0);
            }
            return retVal;
        } else if (type == AttributeDefinition.DOUBLE) {
            double[] retVal = new double[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Double.parseDouble(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.FLOAT) {
            float[] retVal = new float[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Float.parseFloat(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.INTEGER) {
            int[] retVal = new int[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Integer.parseInt(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.LONG) {
            long[] retVal = new long[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Long.parseLong(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.SHORT) {
            short[] retVal = new short[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Short.parseShort(value);
            }
            return retVal;
        } else if (type == MetaTypeFactory.DURATION_TYPE) {
            return convertListToDurationArray(rawValues, attrDef, context, TimeUnit.MILLISECONDS, ignoreWarnings);
        } else if (type == MetaTypeFactory.DURATION_S_TYPE) {
            return convertListToDurationArray(rawValues, attrDef, context, TimeUnit.SECONDS, ignoreWarnings);
        } else if (type == MetaTypeFactory.DURATION_M_TYPE) {
            return convertListToDurationArray(rawValues, attrDef, context, TimeUnit.MINUTES, ignoreWarnings);
        } else if (type == MetaTypeFactory.DURATION_H_TYPE) {
            return convertListToDurationArray(rawValues, attrDef, context, TimeUnit.HOURS, ignoreWarnings);
        } else {
            // STRING, PID_TYPE, TOKEN_TYPE, and all other unknown/invalid types.
            return convertListToStringArray(rawValues, attrDef, context, ignoreWarnings);
        }
    }
13524
def all_to_public(self):
        
        if "private" not in self.modifiers:
            def public_collection(attribute):
                for key in self.collection(attribute):
                    if key not in self.publics:
                        self.publics[key.lower()] = 1
            public_collection("members")
            public_collection("types")
            public_collection("executables")
476677
@NotNull
    public Object[] toArray() {
        return toArray(new IntFunction<Object[]>() {

            @NotNull
            @Override
            public Object[] apply(int value) {
                return new Object[value];
            }
        });
    }
1158385
public Object toArray() {
		if (listeners == EMPTY_OBJECT_ARRAY)
			return Array.newInstance(listenerClass, 0);

		Object[] listenersCopy = listeners;
		Object copy = Array.newInstance(listenerClass, listenersCopy.length);
		System.arraycopy(listenersCopy, 0, copy, 0, listenersCopy.length);
		return copy;
	}
20542
public function toJson() {
    	$result = array();
    	$result['name'] = $this->getName();
    
    	$modifier = "";
    	if ($this->isPublic()) {
    		$modifier = "public";
    	} elseif ($this->isProtected()) {
    		$modifier = "protected";
    	} elseif ($this->isPrivate()) {
    		$modifier = "private";
    	}
    	$result['modifier'] = $modifier;
    	$result['static'] = $this->isStatic();
    	$result['abstract'] = $this->isAbstract();
    	$result['constructor'] = $this->isConstructor();
    	$result['final'] = $this->isFinal();
    	//$result['comment'] = $this->getDocComment();
    	$result['comment'] = $this->getMoufPhpDocComment()->getJsonArray();
    
    	$result['parameters'] = array();
    	$parameters = $this->getParameters();
    	foreach ($parameters as $parameter) {
    		$result['parameters'][] = $parameter->toJson();
    	}
    
    	//$properties = $this->getAnnotations("Property");
    	try {
    		/*if (!empty($properties)) {
    		 $result['moufProperty'] = true;*/
    		
    		// TODO: is there a need to instanciate a  MoufPropertyDescriptor?
    		
    		// If this is a setter only:
    		
    		if ($this->isSetter()) {
	    		$moufPropertyDescriptor = new MoufPropertyDescriptor($this);
	    		$types = $moufPropertyDescriptor->getTypes();
	    		$result['types'] = $types->toJson();
	    		
	    		if ($types->getWarningMessage()) {
	    			$result['classinerror'] = $types->getWarningMessage();
	    		}
    		}
    		
    		/*if ($moufPropertyDescriptor->isAssociativeArray()) {
    			$result['keytype'] = $moufPropertyDescriptor->getKeyType();
    		}
    		if ($moufPropertyDescriptor->isArray()) {
    			$result['subtype'] = $moufPropertyDescriptor->getSubType();
    		}*/
    		//}
    	} catch (\Exception $e) {
    		$result['classinerror'] = $e->getMessage();
    	}
    	
    
    	return $result;
    }
414247
private Struct toStruct(Attributes att) {
	int len = att.getLength();
	Struct sct = new StructImpl();
	for (int i = 0; i < len; i++) {
	    sct.setEL(att.getQName(i), att.getValue(i));
	}
	return sct;
    }
218028
def as_struct_array(*columns):
    
    columns = [np.asarray(c) for c in columns]
    rows = len(columns[0])

    names = ['f'+str(i) for i in range(len(columns))]
    dtype = [(names[i], c.dtype, c.shape[1:]) for i, c in enumerate(columns)]
    data = np.empty(rows, dtype)
    for i, c in enumerate(columns):
        data[names[i]] = c
    return data
747483
function array(obj) {
  if ('array' === type(obj)) return obj;
  if ('arguments' === type(obj)) return Array.prototype.slice.call(obj, 0);

  return obj  // Only transform objects in to an array when they exist.
    ? [obj]
    : [];
}
510377
public static Object convertToArray(final Class type, final List<?> values) {
        final Object exampleArray = Array.newInstance(type, values.size());
        try {
            return values.toArray((Object[]) exampleArray);
        } catch (ClassCastException e) {
            for (int i = 0; i < values.size(); i++) {
                Array.set(exampleArray, i, values.get(i));
            }
            return exampleArray;
        }
    }
373758
public function toArray()
    {
        $reflection = new ReflectionObject($this);

        $properties = $this->propertiesToArray($reflection);
        $methods    = $this->methodsToArray($reflection);

        return array_merge($properties, $methods);
    }