text:
package client

import (
	"context"
	"github.com/cloudfoundry-community/go-cfclient/v3/resource"
	"github.com/cloudfoundry-community/go-cfclient/v3/testutil"
	"net/http"
	"testing"
)

func TestServiceRouteBindings(t *testing.T) {
	g := testutil.NewObjectJSONGenerator(324)
	svcRouteBinding := g.ServiceRouteBinding().JSON
	svcRouteBinding2 := g.ServiceRouteBinding().JSON
	svcRouteBinding3 := g.ServiceRouteBinding().JSON
	svcRouteBinding4 := g.ServiceRouteBinding().JSON
	route := g.Route().JSON
	si := g.ServiceInstance().JSON

	tests := []RouteTest{
		{
			Description: "Create route binding to managed service instance",
			Route: testutil.MockRoute{
				Method:           "POST",
				Endpoint:         "/v3/service_route_bindings",
				Status:           http.StatusCreated,
				RedirectLocation: "https://api.example.org/api/v3/jobs/c33a5caf-77e0-4d6e-b587-5555d339bc9a",
				PostForm: `{
					"relationships": {
					  "route": {
						"data": {
						  "guid": "7304bc3c-7010-11ea-8840-48bf6bec2d78"
						}
					  },
					  "service_instance": {
						"data": {
						  "guid": "e0e4417c-74ee-11ea-a604-48bf6bec2d78"
						}
					  }
					}
				  }`,
			},
			Expected: "c33a5caf-77e0-4d6e-b587-5555d339bc9a",
			Action2: func(c *Client, t *testing.T) (any, any, error) {
				r := resource.NewServiceRouteBindingCreate("7304bc3c-7010-11ea-8840-48bf6bec2d78",
					"e0e4417c-74ee-11ea-a604-48bf6bec2d78")
				return c.ServiceRouteBindings.Create(context.Background(), r)
			},
		},
		{
			Description: "Create route binding to user provided service instance",
			Route: testutil.MockRoute{
				Method:   "POST",
				Endpoint: "/v3/service_route_bindings",
				Output:   g.Single(svcRouteBinding),
				Status:   http.StatusCreated,
				PostForm: `{
					"relationships": {
					  "route": {
						"data": {
						  "guid": "7304bc3c-7010-11ea-8840-48bf6bec2d78"
						}
					  },
					  "service_instance": {
						"data": {
						  "guid": "e0e4417c-74ee-11ea-a604-48bf6bec2d78"
						}
					  }
					}
				  }`,
			},
			Expected:  "",
			Expected2: svcRouteBinding,
			Action2: func(c *Client, t *testing.T) (any, any, error) {
				r := resource.NewServiceRouteBindingCreate("7304bc3c-7010-11ea-8840-48bf6bec2d78",
					"e0e4417c-74ee-11ea-a604-48bf6bec2d78")
				return c.ServiceRouteBindings.Create(context.Background(), r)
			},
		},
		{
			Description: "Delete user provided service instance route binding",
			Route: testutil.MockRoute{
				Method:   "DELETE",
				Endpoint: "/v3/service_route_bindings/3458647f-8358-4427-9a64-9f90392b02f7",
				Status:   http.StatusNoContent,
			},
			Expected: "",
			Action: func(c *Client, t *testing.T) (any, error) {
				return c.ServiceRouteBindings.Delete(context.Background(), "3458647f-8358-4427-9a64-9f90392b02f7")
			},
		},
		{
			Description: "Delete managed service instance route binding",
			Route: testutil.MockRoute{
				Method:           "DELETE",
				Endpoint:         "/v3/service_route_bindings/3458647f-8358-4427-9a64-9f90392b02f7",
				Status:           http.StatusAccepted,
				RedirectLocation: "https://api.example.org/api/v3/jobs/c33a5caf-77e0-4d6e-b587-5555d339bc9a",
			},
			Expected: "c33a5caf-77e0-4d6e-b587-5555d339bc9a",
			Action: func(c *Client, t *testing.T) (any, error) {
				return c.ServiceRouteBindings.Delete(context.Background(), "3458647f-8358-4427-9a64-9f90392b02f7")
			},
		},
		{
			Description: "Get service route binding",
			Route: testutil.MockRoute{
				Method:   "GET",
				Endpoint: "/v3/service_route_bindings/3458647f-8358-4427-9a64-9f90392b02f7",
				Output:   g.Single(svcRouteBinding),
				Status:   http.StatusOK},
			Expected: svcRouteBinding,
			Action: func(c *Client, t *testing.T) (any, error) {
				return c.ServiceRouteBindings.Get(context.Background(), "3458647f-8358-4427-9a64-9f90392b02f7")
			},
		},
		{
			Description: "Get service route binding include route",
			Route: testutil.MockRoute{
				Method:   "GET",
				Endpoint: "/v3/service_route_bindings/3458647f-8358-4427-9a64-9f90392b02f7",
				Output: g.ResourceWithInclude(testutil.ResourceResult{
					Resource: svcRouteBinding,
					Routes:   []string{route},
				}),
				Status: http.StatusOK,
			},
			Expected:  svcRouteBinding,
			Expected2: route,
			Action2: func(c *Client, t *testing.T) (any, any, error) {
				return c.ServiceRouteBindings.GetIncludeRoute(context.Background(), "3458647f-8358-4427-9a64-9f90392b02f7")
			},
		},
		{
			Description: "Get service route binding include service instance",
			Route: testutil.MockRoute{
				Method:   "GET",
				Endpoint: "/v3/service_route_bindings/3458647f-8358-4427-9a64-9f90392b02f7",
				Output: g.ResourceWithInclude(testutil.ResourceResult{
					Resource:         svcRouteBinding,
					ServiceInstances: []string{si},
				}),
				Status: http.StatusOK,
			},
			Expected:  svcRouteBinding,
			Expected2: si,
			Action2: func(c *Client, t *testing.T) (any, any, error) {
				return c.ServiceRouteBindings.GetIncludeServiceInstance(context.Background(), "3458647f-8358-4427-9a64-9f90392b02f7")
			},
		},
		{
			Description: "Get service route binding parameters",
			Route: testutil.MockRoute{
				Method:   "GET",
				Endpoint: "/v3/service_route_bindings/3458647f-8358-4427-9a64-9f90392b02f7/parameters",
				Output: []string{`
					{
					  "foo": "bar",
					  "foz": "baz"
					}`},
				Status: http.StatusOK,
			},
			Expected: `{ "foo": "bar", "foz": "baz" }`,
			Action: func(c *Client, t *testing.T) (any, error) {
				return c.ServiceRouteBindings.GetParameters(context.Background(), "3458647f-8358-4427-9a64-9f90392b02f7")
			},
		},
		{
			Description: "List all service route bindings",
			Route: testutil.MockRoute{
				Method:   "GET",
				Endpoint: "/v3/service_route_bindings",
				Output:   g.Paged([]string{svcRouteBinding}, []string{svcRouteBinding2}),
				Status:   http.StatusOK},
			Expected: g.Array(svcRouteBinding, svcRouteBinding2),
			Action: func(c *Client, t *testing.T) (any, error) {
				return c.ServiceRouteBindings.ListAll(context.Background(), nil)
			},
		},
		{
			Description: "List all service route bindings include routes",
			Route: testutil.MockRoute{
				Method:   "GET",
				Endpoint: "/v3/service_route_bindings",
				Output: g.PagedWithInclude(
					testutil.PagedResult{
						Resources: []string{svcRouteBinding, svcRouteBinding2},
						Routes:    []string{route},
					},
					testutil.PagedResult{
						Resources: []string{svcRouteBinding3, svcRouteBinding4},
					}),
				Status: http.StatusOK},
			Expected:  g.Array(svcRouteBinding, svcRouteBinding2, svcRouteBinding3, svcRouteBinding4),
			Expected2: g.Array(route),
			Action2: func(c *Client, t *testing.T) (any, any, error) {
				return c.ServiceRouteBindings.ListIncludeRoutesAll(context.Background(), nil)
			},
		},
		{
			Description: "List all service route bindings include service instances",
			Route: testutil.MockRoute{
				Method:   "GET",
				Endpoint: "/v3/service_route_bindings",
				Output: g.PagedWithInclude(
					testutil.PagedResult{
						Resources:        []string{svcRouteBinding, svcRouteBinding2},
						ServiceInstances: []string{si},
					},
					testutil.PagedResult{
						Resources: []string{svcRouteBinding3, svcRouteBinding4},
					}),
				Status: http.StatusOK},
			Expected:  g.Array(svcRouteBinding, svcRouteBinding2, svcRouteBinding3, svcRouteBinding4),
			Expected2: g.Array(si),
			Action2: func(c *Client, t *testing.T) (any, any, error) {
				return c.ServiceRouteBindings.ListIncludeServiceInstancesAll(context.Background(), nil)
			},
		},
		{
			Description: "Update service route binding",
			Route: testutil.MockRoute{
				Method:   "PATCH",
				Endpoint: "/v3/service_route_bindings/3458647f-8358-4427-9a64-9f90392b02f7",
				Output:   g.Single(svcRouteBinding),
				Status:   http.StatusOK,
				PostForm: `{
					"metadata": {
					  "labels": {"key": "value"},
					  "annotations": {"note": "detailed information"}
					}
				  }`,
			},
			Expected: svcRouteBinding,
			Action: func(c *Client, t *testing.T) (any, error) {
				r := &resource.ServiceRouteBindingUpdate{
					Metadata: resource.Metadata{
						Labels: map[string]string{
							"key": "value",
						},
						Annotations: map[string]string{
							"note": "detailed information",
						},
					},
				}
				return c.ServiceRouteBindings.Update(context.Background(), "3458647f-8358-4427-9a64-9f90392b02f7", r)
			},
		},
	}
	ExecuteTests(tests, t)
}

redpajama_set_name: RedPajamaGithub


text:
package com.jmelzer.jitty.model.xml.clicktt;

import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.ArrayList;
import java.util.List;

/**
 *
Java-Klasse für anonymous complex type.
 *
 *
Das folgende Schemafragment gibt den erwarteten Content an, der in dieser Klasse enthalten ist.
 *
 *

 * <complexType>
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element ref="{}person" maxOccurs="2"/>
 *       </sequence>
 *       <attribute name="type" use="required">
 *         <simpleType>
 *           <restriction base="{http://www.w3.org/2001/XMLSchema}NMTOKEN">
 *             <enumeration value="double"/>
 *             <enumeration value="single"/>
 *           </restriction>
 *         </simpleType>
 *       </attribute>
 *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}ID" />
 *       <attribute name="team-name" type="{http://www.w3.org/2001/XMLSchema}anySimpleType" />
 *       <attribute name="team-nr" type="{http://www.w3.org/2001/XMLSchema}anySimpleType" />
 *     </restriction>
 *   </complexContent>
 * </complexType>
 *

 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "person"
})
@XmlRootElement(name = "player")
public class Player {

    @XmlElement(required = true)
    protected List<Person> person;
    @XmlAttribute(name = "type", required = true)
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    protected String type;
    @XmlAttribute(name = "id", required = true)
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlID
    @XmlSchemaType(name = "ID")
    protected String id;
    @XmlAttribute(name = "team-name")
    @XmlSchemaType(name = "anySimpleType")
    protected String teamName;
    @XmlAttribute(name = "team-nr")
    @XmlSchemaType(name = "anySimpleType")
    protected String teamNr;

    /**
     * Gets the value of the person property.
     *
     *

     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a set method for the person property.
     *
     *

     * For example, to add a new item, do as follows:
     *

     *    getPerson().add(newItem);
     *

     *
     *
     *

     * Objects of the following type(s) are allowed in the list
     * {@link Person }
     *
     *
     */
    public List<Person> getPerson() {
        if (person == null) {
            person = new ArrayList<Person>();
        }
        return this.person;
    }

    /**
     * Ruft den Wert der type-Eigenschaft ab.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getType() {
        return type;
    }

    /**
     * Legt den Wert der type-Eigenschaft fest.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setType(String value) {
        this.type = value;
    }

    /**
     * Ruft den Wert der id-Eigenschaft ab.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getId() {
        return id;
    }

    /**
     * Legt den Wert der id-Eigenschaft fest.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setId(String value) {
        this.id = value;
    }

    /**
     * Ruft den Wert der teamName-Eigenschaft ab.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getTeamName() {
        return teamName;
    }

    /**
     * Legt den Wert der teamName-Eigenschaft fest.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setTeamName(String value) {
        this.teamName = value;
    }

    /**
     * Ruft den Wert der teamNr-Eigenschaft ab.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getTeamNr() {
        return teamNr;
    }

    /**
     * Legt den Wert der teamNr-Eigenschaft fest.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setTeamNr(String value) {
        this.teamNr = value;
    }

    @Override
    public String toString() {
        return "Player{" +
                "person=" + person +
                ", type='" + type + '\'' +
                ", id='" + id + '\'' +
                ", teamName='" + teamName + '\'' +
                ", teamNr='" + teamNr + '\'' +
                '}';
    }
}


text:
title: CyclomaticComplexity - detekt-api
---

[detekt-api](../../index.html) / [io.gitlab.arturbosch.detekt.api.internal](../index.html) / [CyclomaticComplexity](./index.html)

# CyclomaticComplexity

`class CyclomaticComplexity : `[`DetektVisitor`](../../io.gitlab.arturbosch.detekt.api/-detekt-visitor/index.html)

Counts the cyclomatic complexity of nodes.

### Types

| [Config](-config/index.html) | `data class Config` |

### Constructors

| [<init>](-init-.html) | Counts the cyclomatic complexity of nodes.`CyclomaticComplexity(config: Config)` |

### Properties

| [complexity](complexity.html) | `var complexity: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) |

### Functions

| [visitBinaryExpression](visit-binary-expression.html) | `fun visitBinaryExpression(expression: KtBinaryExpression): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) |
| [visitBreakExpression](visit-break-expression.html) | `fun visitBreakExpression(expression: KtBreakExpression): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) |
| [visitCallExpression](visit-call-expression.html) | `fun visitCallExpression(expression: KtCallExpression): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) |
| [visitContinueExpression](visit-continue-expression.html) | `fun visitContinueExpression(expression: KtContinueExpression): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) |
| [visitIfExpression](visit-if-expression.html) | `fun visitIfExpression(expression: KtIfExpression): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) |
| [visitLoopExpression](visit-loop-expression.html) | `fun visitLoopExpression(loopExpression: KtLoopExpression): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) |
| [visitNamedFunction](visit-named-function.html) | `fun visitNamedFunction(function: KtNamedFunction): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) |
| [visitTryExpression](visit-try-expression.html) | `fun visitTryExpression(expression: KtTryExpression): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) |
| [visitWhenExpression](visit-when-expression.html) | `fun visitWhenExpression(expression: KtWhenExpression): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) |

### Companion Object Properties

| [CONDITIONALS](-c-o-n-d-i-t-i-o-n-a-l-s.html) | `val CONDITIONALS: `[`Set`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html)`<KtSingleValueToken!>` |
| [DEFAULT_NESTING_FUNCTIONS](-d-e-f-a-u-l-t_-n-e-s-t-i-n-g_-f-u-n-c-t-i-o-n-s.html) | `val DEFAULT_NESTING_FUNCTIONS: `[`Set`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>` |

### Companion Object Functions

| [calculate](calculate.html) | `fun calculate(node: KtElement, configure: (Config.() -> `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)`)? = null): `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) |


text:
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-comp-3463',
  templateUrl: './comp-3463.component.html',
  styleUrls: ['./comp-3463.component.css']
})
export class Comp3463Component implements OnInit {

  constructor() { }

  ngOnInit() {
  }

}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using DodoNet;
using DodoNet.Http;

namespace DodoOpenId.OpenId
{
    public class DiscoverRequest
    {
        public static readonly string Google_Discover_OpenID_Endpoint = "https://www.google.com/accounts/o8/id";

        public XrdsDocument XrdsDocument { get; private set; }

        public XrdElement MainElement { get; private set; }

        public Uri ProviderEndpoint
        {
            get
            {
                return MainElement.ServiceUris.FirstOrDefault().Uri;
            }
        }

        public DiscoverRequest() { }

        public void Request(Node localNode, string url)
        {
            var req = new HttpRequest(localNode);
            req.Accept.Add("application/xrds+xml");
            req.Url = url;

            using (var reply = localNode.SendRequest(req))
            {
                XrdsDocument = new XrdsDocument(reply.Body.GetPlainText());
                MainElement = XrdsDocument.XrdElements.FirstOrDefault();

                if (MainElement == null)
                    throw new NullReferenceException("Documento XRDS sin elementos");
            }
        }
    }
}


text:
package org.nd4j.linalg.api.shape;

import com.google.common.primitives.Ints;

import org.nd4j.bytebuddy.shape.IndexMapper;
import org.nd4j.bytebuddy.shape.OffsetMapper;
import org.nd4j.bytebuddy.shape.ShapeMapper;
import org.nd4j.linalg.api.buffer.DataBuffer;
import org.nd4j.linalg.api.buffer.DataBuffer.AllocationMode;
import org.nd4j.linalg.api.complex.IComplexNDArray;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.api.ops.Op;
import org.nd4j.linalg.factory.Nd4j;
import org.nd4j.linalg.indexing.INDArrayIndex;
import org.nd4j.linalg.indexing.NDArrayIndex;
import org.nd4j.linalg.indexing.ShapeOffsetResolution;
import org.nd4j.linalg.util.ArrayUtil;

import java.util.*;

/**
 * Encapsulates all shape related logic (vector of 0 dimension is a scalar is equivalent to
 * a vector of length 1...)
 *
 * @author Adam Gibson
 */
public class Shape {

    private static IndexMapper[] indexMappers = new IndexMapper[255];
    private static IndexMapper[] indexMappersC = new IndexMapper[255];
    private static OffsetMapper[] mappers = new OffsetMapper[255];
    static {
        for(int i = 0; i < 255; i++) {
            indexMappersC[i] = ShapeMapper.getInd2SubInstance('c',i);
            indexMappers[i] = ShapeMapper.getInd2SubInstance('f',i);
            mappers[i] = ShapeMapper.getOffsetMapperInstance(i);
        }
    }

    /**
     * Create a copy of the matrix
     * where the new offset is zero
     * @param arr the array to copy to offset 0
     * @return the same array if offset is zero
     * otherwise a copy of the array with
     * elements set to zero
     */
    public static INDArray toOffsetZero(INDArray arr) {
        if(arr.offset() < 1 && arr.data().length() == arr.length() || arr instanceof  IComplexNDArray && arr.length() * 2 == arr.data().length())
            if(arr.ordering() == 'f' && arr.stride(-1) != arr.elementStride() ||
                    arr.ordering() == 'c' && arr.stride(0) != arr.elementStride())
                return arr;

        if(arr.isRowVector()) {
            if(arr instanceof IComplexNDArray) {
                IComplexNDArray ret = Nd4j.createComplex(arr.shape());
                for(int i = 0; i < ret.length(); i++)
                    ret.putScalar(i, ((IComplexNDArray) arr).getComplex(i));
                return ret;
            }
            else {
                INDArray ret = Nd4j.create(arr.shape());
                for(int i = 0; i < ret.length(); i++)
                    ret.putScalar(i,arr.getDouble(i));
                return ret;
            }
        }

        if(arr instanceof IComplexNDArray) {
            IComplexNDArray ret = Nd4j.createComplex(arr.shape());
            for(int i = 0; i < ret.slices(); i++)
                ret.putSlice(i,arr.slice(i));
            return ret;
        }
        else {
            INDArray ret = Nd4j.create(arr.shape(),arr.ordering());
            ret.assign(arr);
            return ret;
        }
    }

    /**
     * Create a copy of the matrix
     * where the new offset is zero
     * @param arr the array to copy to offset 0
     * @return the same array if offset is zero
     * otherwise a copy of the array with
     * elements set to zero
     */
    public static INDArray toOffsetZeroCopy(INDArray arr) {
        if(arr.isRowVector()) {
            if(arr instanceof IComplexNDArray) {
                IComplexNDArray ret = Nd4j.createComplex(arr.shape());
                for(int i = 0; i < ret.length(); i++)
                    ret.putScalar(i, ((IComplexNDArray) arr).getComplex(i));
                return ret;
            }
            else {
                INDArray ret = Nd4j.create(arr.shape());
                for(int i = 0; i < ret.length(); i++)
                    ret.putScalar(i,arr.getDouble(i));
                return ret;
            }
        }

        if(arr instanceof IComplexNDArray) {
            IComplexNDArray ret = Nd4j.createComplex(arr.shape());
            for(int i = 0; i < ret.slices(); i++)
                ret.putSlice(i,arr.slice(i));
            return ret;
        }
        else {

        	if(arr.offset() == 0 && arr.data().allocationMode() == AllocationMode.HEAP
        			&& arr.length() == arr.data().length() && arr.ordering() == Nd4j.order()
        			&& strideDescendingCAscendingF(arr.ordering(),arr.stride())) {
        		Object array = arr.data().array();

        		if( array instanceof float[]) {
        			float[] orig = (float[])array;
        			float[] out = Arrays.copyOf(orig, orig.length);
        			DataBuffer floatBuffer = Nd4j.createBuffer(out);

        			int[] newShape = arr.shape();
        			newShape = Arrays.copyOf(newShape, newShape.length);
        			int[] newStride = arr.stride();
        			newStride = Arrays.copyOf(newStride, newStride.length);

        			return Nd4j.create(floatBuffer,newShape,newStride,0,arr.ordering());

        		} else if( array instanceof double[] ){
        			double[] orig = (double[])array;
        			double[] out = Arrays.copyOf(orig, orig.length);
        			DataBuffer doubleBuffer = Nd4j.createBuffer(out);

        			int[] newShape = arr.shape();
        			newShape = Arrays.copyOf(newShape, newShape.length);
        			int[] newStride = arr.stride();
        			newStride = Arrays.copyOf(newStride, newStride.length);

        			return Nd4j.create(doubleBuffer,newShape,newStride,0,arr.ordering());
        		}
        	}

            INDArray ret = Nd4j.create(arr.shape());
            for(int i = 0; i < arr.vectorsAlongDimension(0); i++) {
                ret.vectorAlongDimension(i,0).assign(arr.vectorAlongDimension(i,0));
            }

            return ret;
        }
    }

    /**
     * Get a double based on the array and given indices
     * @param arr the array to retrieve the double from
     * @param indices the indices to iterate over
     * @return the double at the specified index
     */
    public static double getDouble(INDArray arr,int...indices) {
        int offset = getOffset(arr.offset(),arr.shape(),arr.stride(),indices);
        return arr.data().getDouble(offset);
    }

    /**
     * Get an offset for retrieval
     * from a data buffer
     * based on the given
     * shape stride and given indices
     * @param baseOffset the offset to start from
     * @param shape the shape of the array
     * @param stride the stride of the array
     * @param indices the indices to iterate over
     * @return the double at the specified index
     */
    public static int getOffset(int baseOffset,int[] shape,int[] stride,int...indices) {
        return mappers[shape.length].getOffset(baseOffset, shape, stride, indices);
    }

    /**
     * Output an int array for a particular dimension
     * @param axes the axes
     * @param shape the current shape
     * @return
     */
    public static int[] sizeForAxes(int[] axes, int[] shape) {
        int[] ret = new int[shape.length];
        for (int i = 0; i < axes.length; i++) {
            ret[i] = shape[axes[i]];
        }
        return ret;
    }

    /**
     * Returns whether the given shape is a vector
     *
     * @param shape the shape to test
     * @return whether the given shape is a vector
     */
    public static boolean isVector(int[] shape) {
        if (shape.length > 2 || shape.length < 1)
            return false;
        else {
            int len = ArrayUtil.prod(shape);
            return shape[0] == len || shape[1] == len;
        }
    }

    /**
     * Returns whether the passed in shape is a matrix
     *
     * @param shape whether the passed in shape is a matrix
     * @return true if the shape is a matrix false otherwise
     */
    public static boolean isMatrix(int[] shape) {
        if (shape.length != 2)
            return false;
        return !isVector(shape);
    }

    /**
     * Gets rid of any singleton dimensions of the given array
     *
     * @param shape the shape to squeeze
     * @return the array with all of the singleton dimensions removed
     */
    public static int[] squeeze(int[] shape) {
        if(isColumnVectorShape(shape))
            return shape;

        List<Integer> ret = new ArrayList<>();

        //strip all but last dimension
        for (int i = 0; i < shape.length; i++)
            if (shape[i] != 1)
                ret.add(shape[i]);
        return ArrayUtil.toArray(ret);
    }

    /**
     * Keep all the non one dimensions
     * @param dimensions the dimensions to start with
     * @param shape the shapes to inspect
     * @return the non one dimensions of the given input
     */
    public static int[] nonOneDimensions(int[] dimensions,int[] shape) {
        if(dimensions.length != shape.length)
            throw new IllegalArgumentException("Dimensions and shape must be the same length");

        List<Integer> list = new ArrayList<>();
        for(int i = 0; i < dimensions.length; i++) {
            if(shape[i] != 1) {
                list.add(i);
            }
        }

        return Ints.toArray(list);
    }

    /**
     * Get rid ones in the shape when
     * its not a vector
     * @param original the original shape
     *                 to prune
     * @return the pruned array
     */
    public static int[] leadingAndTrailingOnes(int[] original) {
        List<Integer> ints = new ArrayList<>();
        if (!Shape.isVector(original)) {
            for (int i = 0; i < original.length; i++) {
                if(original[i] != 1)
                    ints.add(original[i]);
            }

            return Ints.toArray(ints);
        }
        return original;
    }

    /**
     * Returns whether 2 shapes are equals by checking for dimension semantics
     * as well as array equality
     *
     * @param shape1 the first shape for comparison
     * @param shape2 the second shape for comparison
     * @return whether the shapes are equivalent
     */
    public static boolean shapeEquals(int[] shape1, int[] shape2) {
        if (isColumnVectorShape(shape1)) {
            if (isColumnVectorShape(shape2)) {
                return Arrays.equals(shape1, shape2);
            }

        }

        if (isRowVectorShape(shape1)) {
            if (isRowVectorShape(shape2)) {
                int[] shape1Comp = squeeze(shape1);
                int[] shape2Comp = squeeze(shape2);
                return Arrays.equals(shape1Comp, shape2Comp);
            }
        }

        shape1 = squeeze(shape1);
        shape2 = squeeze(shape2);

        return scalarEquals(shape1, shape2) || Arrays.equals(shape1, shape2);
    }

    /**
     * Returns true if the given shapes are both scalars (0 dimension or shape[0] == 1)
     *
     * @param shape1 the first shape for comparison
     * @param shape2 the second shape for comparison
     * @return whether the 2 shapes are equal based on scalar rules
     */
    public static boolean scalarEquals(int[] shape1, int[] shape2) {
        if (shape1.length == 0) {
            if (shape2.length == 1 && shape2[0] == 1)
                return true;
        } else if (shape2.length == 0) {
            if (shape1.length == 1 && shape1[0] == 1)
                return true;
        }

        return false;
    }

    /**
     * Returns true if the given shape is of length 1
     * or provided the shape length is 2:
     * element 0 is 1
     * @param shape the shape to check
     * @return true if the above conditions hold,false otherwise
     */
    public static boolean isRowVectorShape(int[] shape) {
        return
                (shape.length == 2
                        && shape[0] == 1) ||
                        shape.length == 1;

    }

    /**
     * Returns true if the given shape is length 2 and
     * the size at element 1 is 1
     * @param shape the shape to check
     * @return true if the above listed conditions
     * hold false otherwise
     */
    public static boolean isColumnVectorShape(int[] shape) {
        return
                (shape.length == 2
                        && shape[1] == 1);

    }

    /**
     * A port of numpy's stride resolution algorithm
     * for multiple arrays
     * @param arrays the arrays to get concat strides for
     * @return the resolved strides for concat
     */
    public static int[] createConcatStrides(INDArray...arrays) {
        int rank = arrays[0].rank();
        for(INDArray arr : arrays) {
            if(arr.rank() != rank)
                throw new IllegalArgumentException("All arrays must have same rank");
        }

        int[] ret = new int[rank];

        int i0, i1, ipos, ax_j0, ax_j1, iarrays;

         /* Initialize the strideperm values to the identity. */
        for (i0 = 0; i0 < rank; i0++) {
            ret[i0] = i0;
        }

    /*
     * This is the same as the custom stable insertion sort in
     * the NpyIter object, but sorting in the reverse order as
     * in the iterator. The iterator sorts from smallest stride
     * to biggest stride (Fortran order), whereas here we sort
     * from biggest stride to smallest stride (C order).
     */
        for (i0 = 1; i0 < rank; i0++) {

            ipos = i0;
            ax_j0 = ret[i0];

            for (i1 = i0 - 1; i1 >= 0; i1--) {
                boolean ambig = true, shouldSwap = false;

                ax_j1 = ret[i1];

                for (iarrays = 0; iarrays < arrays.length; ++iarrays) {
                    if (arrays[iarrays].size(ax_j0) != 1 &&
                            arrays[iarrays].size(ax_j1) != 1) {
                        if (Math.abs(arrays[iarrays].stride(ax_j0)) <=
                                Math.abs(arrays[iarrays].size(ax_j1))) {
                        /*
                         * Set swap even if it's not ambiguous already,
                         * because in the case of conflicts between
                         * different operands, C-order wins.
                         */
                            shouldSwap = false;
                        }
                        else {
                        /* Only set swap if it's still ambiguous */
                            if (ambig) {
                                shouldSwap = true;
                            }
                        }

                    /*
                     * A comparison has been done, so it's
                     * no longer ambiguous
                     */
                        ambig = false;
                    }
                }
            /*
             * If the comparison was unambiguous, either shift
             * 'ipos' to 'i1' or stop looking for an insertion point
             */
                if (!ambig) {
                    if (shouldSwap) {
                        ipos = i1;
                    }
                    else {
                        break;
                    }
                }
            }

        /* Insert out_strideperm[i0] into the right place */
            if (ipos != i0) {
                for (i1 = i0; i1 > ipos; i1--) {
                    ret[i1] = ret[i1 - 1];
                }

                ret[ipos] = ax_j0;
            }
        }

        return ret;

    }

    /**
     * A port of numpy's reshaping algorithm that leverages
     * no copy where possible and returns
     * null if the reshape
     * couldn't happen without copying
     * @param arr  the array to reshape
     * @param newShape the new shape
     * @param isFOrder whether the array will be fortran ordered or not
     * @return null if a reshape isn't possible, or a new ndarray
     */
    public static  INDArray newShapeNoCopy(INDArray arr, int[] newShape, boolean isFOrder) {
        int oldnd;
        int[] olddims = ArrayUtil.copy(arr.shape());
        int[] oldstrides = ArrayUtil.copy(arr.stride());
        int np, op, last_stride;
        int oi, oj, ok, ni, nj, nk;
        int[] newStrides = new int[newShape.length];
        oldnd = 0;
    /*
     * Remove axes with dimension 1 from the old array. They have no effect
     * but would need special cases since their strides do not matter.
     */
        for (oi = 0; oi < arr.rank(); oi++) {
            if (arr.size(oi) != 1) {
                olddims[oldnd] = arr.size(oi);
                oldstrides[oldnd] = arr.stride(oi);
                oldnd++;
            }
        }

        np = 1;
        for (ni = 0; ni < newShape.length; ni++) {
            np *= newShape[ni];
        }
        op = 1;
        for (oi = 0; oi < oldnd; oi++) {
            op *= olddims[oi];
        }
        if (np != op) {
        /* different total sizes; no hope */
            return null;
        }

        if (np == 0) {
        /* the current code does not handle 0-sized arrays, so give up */
            return null;
        }

    /* oi to oj and ni to nj give the axis ranges currently worked with */
        oi = 0;
        oj = 1;
        ni = 0;
        nj = 1;
        while (ni < newShape.length && oi < oldnd) {
            np = newShape[ni];
            op = olddims[oi];

            while (np != op) {
                if (np < op) {
                /* Misses trailing 1s, these are handled later */
                    np *= newShape[nj++];
                } else {
                    op *= olddims[oj++];
                }
            }

        /* Check whether the original axes can be combined */
            for (ok = oi; ok < oj - 1; ok++) {
                if (isFOrder) {
                    if (oldstrides[ok + 1] != olddims[ok] * oldstrides[ok]) {
                     /* not contiguous enough */
                        return null;
                    }
                }
                else {
                /* C order */
                    if (oldstrides[ok] != olddims[ok+1]*oldstrides[ok+1]) {
                    /* not contiguous enough */
                        return null;
                    }
                }
            }

             /* Calculate new strides for all axes currently worked with */
            if (isFOrder) {
                newStrides[ni] = oldstrides[oi];
                for (nk = ni + 1; nk < nj; nk++) {
                    newStrides[nk] = newStrides[nk - 1]* newShape[nk - 1];
                }
            }
            else {
            /* C order */
                newStrides[nj - 1] = oldstrides[oj - 1];
                for (nk = nj - 1; nk > ni; nk--) {
                    newStrides[nk - 1] = newStrides[nk]* newShape[nk];
                }
            }
            ni = nj++;
            oi = oj++;
        }

    /*
     * Set strides corresponding to trailing 1s of the new shape.
     */
        if (ni >= 1) {
            last_stride = newStrides[ni - 1];
        }
        else {
            last_stride = arr.elementStride();
        }
        if (isFOrder) {
            if(ni >= 1)
                last_stride *= newShape[ni - 1];
        }
        for (nk = ni; nk < newShape.length; nk++) {
            newStrides[nk] = last_stride;
        }

        if(arr instanceof IComplexNDArray)
            return Nd4j.createComplex(arr.data(),newShape,newStrides,arr.offset());

        return Nd4j.create(arr.data(),newShape,newStrides,arr.offset());
    }

    /**
     * Infer order from
     * @param shape the shape to infer by
     * @param stride the stride to infer by
     * @param elementStride the element stride to start at
     * @return the storage order given shape and element stride
     */
    public static boolean cOrFortranOrder(int[] shape,int[] stride,int elementStride) {
        int sd;
        int dim;
        int i;
        boolean cContiguous = true;
        boolean isFortran = true;

        sd = 1;
        for (i = shape.length - 1; i >= 0; --i) {
            dim = shape[i];

            if (stride[i] != sd) {
                cContiguous = false;
                break;
            }
        /* contiguous, if it got this far */
            if (dim == 0) {
                break;
            }
            sd *= dim;

        }

    /* check if fortran contiguous */
        sd = elementStride;
        for (i = 0; i < shape.length; ++i) {
            dim = shape[i];
            if (stride[i] != sd) {
                isFortran = false;
            }
            if (dim == 0) {
                break;
            }
            sd *= dim;

        }

        return cContiguous || isFortran;

    }

    /**
     * Infer order from
     * @param shape the shape to infer by
     * @param stride the stride to infer by
     * @param elementStride the element stride to start at
     * @return the storage order given shape and element stride
     */
    public static char getOrder(int[] shape,int[] stride,int elementStride) {
        int sd;
        int dim;
        int i;
        boolean cContiguous = true;
        boolean isFortran = true;

        sd = 1;
        for (i = shape.length - 1; i >= 0; --i) {
            dim = shape[i];

            if (stride[i] != sd) {
                cContiguous = false;
                break;
            }
        /* contiguous, if it got this far */
            if (dim == 0) {
                break;
            }
            sd *= dim;

        }

    /* check if fortran contiguous */
        sd = elementStride;
        for (i = 0; i < shape.length; ++i) {
            dim = shape[i];
            if (stride[i] != sd) {
                isFortran = false;
            }
            if (dim == 0) {
                break;
            }
            sd *= dim;

        }

        if(isFortran && cContiguous)
            return 'a';
        else if(isFortran && !cContiguous)
            return 'f';
        else if(!isFortran && !cContiguous)
            return 'c';
        else
            return 'c';

    }

    /**
     * Infer the order for the ndarray based on the
     * array's strides
     * @param arr the array to get the
     *            ordering for
     * @return the ordering for the given array
     */
    public static char getOrder(INDArray arr) {
        return getOrder(arr.shape(),arr.stride(),arr.elementStride());
    }

    /**
     * Convert the given index (such as 1,1)
     * to a linear index
     * @param shape the shape of the indexes to convert
     * @param indices the index to convert
     * @return the linear index given the shape
     * and indices
     */
    public static int sub2Ind(int[] shape,int[] indices) {
        int index = 0;
        int shift = 1;
        for(int i = 0; i < shape.length; i++) {
            index += shift * indices[i];
            shift *= shape[i];
        }
        return index;
    }

    /**
     * Convert a linear index to
     * the equivalent nd index
     * @param shape the shape of the dimensions
     * @param index the index to map
     * @param numIndices the number of total indices (typically prod of shape(
     * @return the mapped indexes along each dimension
     */
    public static int[] ind2sub(int[] shape,int index,int numIndices) {
        IndexMapper mapper = indexMappers[shape.length];

     /*   int denom = numIndices;
        int[] ret = new int[shape.length];
        for(int i = ret.length - 1; i >= 0; i--) {
            denom /= shape[i];
            ret[i] = index / denom;
            index %= denom;

        }*/
        return mapper.ind2sub(shape, index, numIndices, 'f');
    }

    /**
     * Convert a linear index to
     * the equivalent nd index.
     * Infers the number of indices from the specified shape.
     *
     * @param shape the shape of the dimensions
     * @param index the index to map
     * @return the mapped indexes along each dimension
     */
    public static int[] ind2sub(int[] shape,int index) {
        return ind2sub(shape, index, ArrayUtil.prod(shape));
    }

    /**
     * Convert a linear index to
     * the equivalent nd index based on the shape of the specified ndarray.
     * Infers the number of indices from the specified shape.
     *
     * @param arr the array to compute the indexes
     *            based on
     * @param index the index to map
     * @return the mapped indexes along each dimension
     */
    public static int[] ind2sub(INDArray arr,int index) {
        return ind2sub(arr.shape(), index, ArrayUtil.prod(arr.shape()));
    }

    /**
     * Convert a linear index to
     * the equivalent nd index
     * @param shape the shape of the dimensions
     * @param index the index to map
     * @param numIndices the number of total indices (typically prod of shape(
     * @return the mapped indexes along each dimension
     */
    public static int[] ind2subC(int[] shape,int index,int numIndices) {
        IndexMapper mapper = indexMappersC[shape.length];
      /*
        int denom = numIndices;
        int[] ret = new int[shape.length];
        for(int i = 0; i < shape.length; i++) {
            denom /= shape[i];
            ret[i] = index / denom;
            index %= denom;

        }
        return ret;*/
        return mapper.ind2sub(shape, index, numIndices, 'c');
    }

    /**
     * Checks the following:
     * each x,y,z is offset zero
     * op.n() is == data buffer.length()
     * all strides are equal
     * @param op the op to check
     * @return true if the above conditions are met
     */
    public static boolean opIsWholeBufferWithMatchingStrides(Op op) {
        if(op.y() != null) {
           return op.x().offset() == 0 && op.n() == op.x().data().length()
                   && op.y().offset() == 0 && op.y().data().length() == op.n()
                   &&
                   op.z().offset() == 0 && op.z().offset() == 0 && op.z().data().length() == op.n()
                   && Arrays.equals(op.x().stride(),op.y().stride()) && Arrays.equals(op.x().stride(),op.z().stride()) && !(op.x() instanceof IComplexNDArray || op.y() instanceof IComplexNDArray);

        }
        else {
            return op.x().offset() == 0 && op.n() == op.x().data().length()
                    &&
                    op.z().offset() == 0 && op.z().offset() == 0 && op.z().data().length() == op.n() &&
                    Arrays.equals(op.x().stride(),op.z().stride()) && !(op.x() instanceof IComplexNDArray || op.y() instanceof IComplexNDArray);
        }
    }

    /**
     * Checks the following:
     * each x,y,z is offset zero
     * op.n() is == data buffer.length()
     * all strides are equal
     * @param op the op to check
     * @return true if the above conditions are met
     */
    public static boolean opIsWithMatchingStrides(Op op) {
        if(op.y() != null) {
            return op.x().offset() == 0 && op.n() == op.x().data().length()
                    && op.y().offset() == 0
                    &&
                    op.z().offset() == 0 && op.z().offset() == 0
                    && Arrays.equals(op.x().stride(),op.y().stride()) && Arrays.equals(op.x().stride(),op.z().stride()) && !(op.x() instanceof IComplexNDArray || op.y() instanceof IComplexNDArray);

        }
        else {
            return op.x().offset() == 0
                    &&
                    op.z().offset() == 0 && op.z().offset() == 0 &&
                    Arrays.equals(op.x().stride(),op.z().stride()) && !(op.x() instanceof IComplexNDArray || op.y() instanceof IComplexNDArray);
        }
    }

    /**
     * Convert a linear index to
     * the equivalent nd index.
     * Infers the number of indices from the specified shape.
     *
     * @param shape the shape of the dimensions
     * @param index the index to map
     * @return the mapped indexes along each dimension
     */
    public static int[] ind2subC(int[] shape,int index) {
        return ind2subC(shape, index, ArrayUtil.prod(shape));
    }

    /**
     * Convert a linear index to
     * the equivalent nd index based on the shape of the specified ndarray.
     * Infers the number of indices from the specified shape.
     *
     * @param arr the array to compute the indexes
     *            based on
     * @param index the index to map
     * @return the mapped indexes along each dimension
     */
    public static int[] ind2subC(INDArray arr,int index) {
        return ind2subC(arr.shape(), index, ArrayUtil.prod(arr.shape()));
    }

    /**
     * Compute the offset for the given array
     * given the indices
     * @param arr the array to compute the offset for
     * @param indexes the indexes along each dimension to create the offset for
     * @return the offset for the given array and indexes
     */
    public static int offsetFor(INDArray arr,int[] indexes) {
        ShapeOffsetResolution resolution = new ShapeOffsetResolution(arr);
        resolution.exec(Shape.toIndexes(indexes));
        return resolution.getOffset();
    }

    /**
     * Compute the offset for a given index
     * @param arr the array to compute the offset for
     * @param index the linear index to compute the offset for
     * @return the offset for the given linear index
     */
    public static int offsetFor(INDArray arr,int index) {
        int[] indexes = arr.ordering() == 'c' ? Shape.ind2subC(arr,index) : Shape.ind2sub(arr, index);
        return offsetFor(arr, indexes);
    }

    /**
     * Assert the both shapes are the same length
     * and shape[i] < lessThan[i]
     * @param shape the shape to check
     * @param lessThan the shape to assert against
     */
    public static void assertShapeLessThan(int[] shape,int[] lessThan) {
        if(shape.length != lessThan.length) {
            throw new IllegalArgumentException("Shape length must be == less than length");
        }
        for(int i = 0; i < shape.length; i++) {
            if(shape[i] >= lessThan[i])
                throw new IllegalStateException("Shape[" + i + "] should be less than lessThan[" + i + "]");
        }
    }

    /**
     * Returns a permutation of the dimensions
     * with all 1s moved to end
     * @param shape the shape to permute
     * @return the permuted axes with all moving towards
     * end
     */
    public static int[] moveOnesToEnd(int[] shape) {
        List<Integer> nonOnes = new ArrayList<>();
        List<Integer> ones = new ArrayList<>();
        for(int i = 0; i < shape.length; i++) {
            if(shape[i] == 1)
                ones.add(i);
            else
                nonOnes.add(i);
        }

        return Ints.concat(Ints.toArray(nonOnes), Ints.toArray(ones));
    }

    /**
     * Convert the given int indexes
     * to nd array indexes
     * @param indices the indices to convert
     * @return the converted indexes
     */
    public static INDArrayIndex[] toIndexes(int[] indices) {
        INDArrayIndex[] ret = new INDArrayIndex[indices.length];
        for(int i = 0; i < ret.length; i++)
            ret[i] = new NDArrayIndex(indices[i]);
        return ret;
    }

    public static int[] newStrides(int[] strides,int newLength,INDArrayIndex[] indexes) {
        if(strides.length > newLength) {
            int[] newStrides = new int[strides.length - 1];
            for(int i = 0; i < newStrides.length; i++) {
                newStrides[i] = strides[i + 1];
            }
            strides = newStrides;
        }

        return strides;
    }

    public static int[] newOffsets(int[] offsets,int newLength,INDArrayIndex[] indexes) {
        if(offsets.length > newLength) {
            int[] newOffsets = new int[offsets.length - 1];
            for(int i = 0; i < newOffsets.length; i++) {
                newOffsets[i] = offsets[i + 1];

            }

            offsets = newOffsets;
        }

        return offsets;
    }

    public static int[] squeezeOffsets(int[] shape,int[] offsets) {
        //bump offsets
        List<Integer> squeezeIndices = new ArrayList<>();
        for(int i = 0; i < shape.length; i++)
            if(offsets[i] == 0)
                squeezeIndices.add(i);
        int[] ret = ArrayUtil.removeIndex(offsets, Ints.toArray(squeezeIndices));
        int delta = Math.abs(ret.length - shape.length);
        if(delta == 0)
            return ret;
        else {
            if(ret.length > shape.length)
                throw new IllegalStateException("Unable to squeeze offsets");
            int[] retOffsets = new int[shape.length];
            System.arraycopy(ret,0,retOffsets,0,ret.length);
            return retOffsets;
        }
    }

    /**
     * Returns true for the case where
     * singleton dimensions are being compared
     *
     * @param test1 the first to test
     * @param test2 the second to test
     * @return true if the arrays
     * are equal with the singleton dimension omitted
     */
    public static boolean squeezeEquals(int[] test1, int[] test2) {
        int[] s1 = squeeze(test1);
        int[] s2 = squeeze(test2);
        return scalarEquals(s1, s2) || Arrays.equals(s1, s2);
    }

    /** Check if strides are in order suitable for non-strided mmul etc.
     * Returns true if c order and strides are descending [100,10,1] etc
     * Returns true if f order and strides are ascending [1,10,100] etc
     * False otherwise.
     * @param order Order of INDArray
     * @param strides Strides of INDArray
     * @return true if c+descending, f+ascending, false otherwise
     */
    public static boolean strideDescendingCAscendingF(char order, int[] strides ){
    	if(order=='c'){	//Expect descending. [100,10,1] etc
    		for( int i=1; i<strides.length; i++ ) if(strides[i-1]<=strides[i]) return false;
    		return true;
    	} else if(order=='f'){//Expect ascending. [1,10,100] etc
    		for( int i=1; i<strides.length; i++ ) if(strides[i-1]>=strides[i]) return false;
    		return true;
    	} else {
    		throw new RuntimeException("Invalid order: not c or f");
    	}
    }
}


text:
package org.lwjgl.system;

import javax.annotation.*;
import java.net.*;
import java.nio.channels.*;
import java.nio.file.*;
import java.util.function.*;

import static org.lwjgl.system.APIUtil.*;
import static org.lwjgl.system.Checks.*;

/**
 * Handles loading of native resources in LWJGL. [INTERNAL USE ONLY]
 *
 *
This class uses the same mechanism as {@link Library} for loading shared libraries. The resource name could be an absolute path, or a relative path that
 * is resolved via {@code org.lwjgl.librarypath}, {@code java.library.path}, or even the class/module-path. When the resource is detected in the
 * class/module-path, it is extracted automatically to {@code org.lwjgl.librarypath} via the {@code SharedLibraryLoader}.

 */
public final class LibraryResource {

    static {
        Library.initialize();
    }

    private LibraryResource() {}

    /** Calls {@link #load(Class, String, String)} using {@code LibraryResource.class} as the context parameter. */
    public static Path load(String module, String name) {
        return load(LibraryResource.class, module, name);
    }

    /**
     * Loads a library resource.
     *
     * @param context the class to use to discover the library resource in the classpath
     * @param module  the module to which the resource belongs
     * @param name    the resource name
     *
     * @return the library resource path
     *
     * @throws IllegalStateException if the resource could not be found
     */
    @SuppressWarnings("try")
    public static Path load(Class<?> context, String module, String name) {
        return load(context, module, name, false, true);
    }

    /**
     * Loads a library resource.
     *
     * @param context          the class to use to discover the library resource in the classpath
     * @param module           the module to which the resource belongs
     * @param name             the resource name
     * @param bundledWithLWJGL whether the default LWJGL distribution includes the  resource. If true, LWJGL will also try to find the shared library under the
     *                         {@code <platform>/<arch>/<module>} subfolder.
     *
     * @return the library resource path
     *
     * @throws IllegalStateException if the resource could not be found
     */
    @SuppressWarnings("try")
    public static Path load(Class<?> context, String module, String name, boolean bundledWithLWJGL) {
        return load(context, module, name, bundledWithLWJGL, true);
    }

    @SuppressWarnings("try")
    private static Path load(Class<?> context, String module, String name, boolean bundledWithLWJGL, boolean printError) {
        if (DEBUG) {
            DEBUG_STREAM.print(
                "[LWJGL] Loading library resource: " + name +
                "\n\tModule: " + module +
                "\n"
            );
        }

        // METHOD 1: absolute path
        Path path = Paths.get(name);
        if (path.isAbsolute()) {
            if (!Files.exists(path)) {
                if (printError) {
                    printError();
                }
                throw new IllegalStateException("Failed to locate library resource: " + name);
            }
            apiLogMore("Success");
            return path;
        }

        // METHOD 2: org.lwjgl.librarypath
        URL resourceURL = Library.findResource(context, module, name, bundledWithLWJGL);
        if (resourceURL == null) {
            path = loadFromLibraryPath(module, name, bundledWithLWJGL);
            if (path != null) {
                return path;
            }
        } else {
            boolean debugLoader = Configuration.DEBUG_LOADER.get(false);
            try {
                String regular = Library.getRegularFilePath(resourceURL);
                if (regular != null) {
                    apiLogMore("Loaded from classpath: " + regular);
                    return Paths.get(regular);
                }

                // Always use the SLL if the resource is found in the classpath,
                // so that newer versions can be detected.
                if (debugLoader) {
                    apiLogMore("Using SharedLibraryLoader...");
                }
                // Extract from classpath and try org.lwjgl.librarypath
                try (FileChannel ignored = SharedLibraryLoader.load(name, name, resourceURL, null)) {
                    path = loadFromLibraryPath(module, name, bundledWithLWJGL);
                    if (path != null) {
                        return path;
                    }
                }
            } catch (Exception e) {
                if (debugLoader) {
                    e.printStackTrace(DEBUG_STREAM);
                }
            }
        }

        // METHOD 3: java.library.path
        String paths = System.getProperty(Library.JAVA_LIBRARY_PATH);
        if (paths != null) {
            path = load(module, name, bundledWithLWJGL, Library.JAVA_LIBRARY_PATH, paths);
            if (path != null) {
                return path;
            }
        }

        if (printError) {
            printError();
        }
        throw new IllegalStateException("Failed to locate library resource: " + name);
    }

    @Nullable
    private static Path loadFromLibraryPath(String module, String libName, boolean bundledWithLWJGL) {
        String paths = Configuration.LIBRARY_PATH.get();
        if (paths == null) {
            return null;
        }
        return load(module, libName, bundledWithLWJGL, Configuration.LIBRARY_PATH.getProperty(), paths);
    }

    @Nullable
    private static Path load(String module, String name, boolean bundledWithLWJGL, String property, String paths) {
        Path resource = Library.findFile(paths, module, name, bundledWithLWJGL);
        if (resource == null) {
            apiLogMore(name + " not found in " + property + "=" + paths);
            return null;
        }

        apiLogMore("Loaded from " + property + ": " + resource);
        return resource;
    }

    /**
     * Loads a library resource using {@link #load(String, String)} with the name specified by {@code name}. If {@code name} is not set,
     * {@link #load(String, String)} will be called with the names specified by {@code defaultNames}. The first successful will be returned.
     *
     * @param name         a {@link Configuration} that specifies the resource name
     * @param defaultNames the default resource name(s)
     *
     * @return the library resource path
     *
     * @throws IllegalStateException if the resource could not be found
     */
    public static Path load(Class<?> context, String module, Configuration<String> name, String... defaultNames) {
        return load(context, module, name, null, defaultNames);
    }

    /**
     * Loads a library resource using {@link #load(Class, String, String) load} with the name specified by {@code name}. If {@code name} is not set,
     * {@code load} will be called with the names specified by {@code defaultNames}. The first successful will be returned. If the resource could
     * not be found, the {@code fallback} will be called.
     *
     * @param name         a {@link Configuration} that specifies the resource name
     * @param fallback     fallback to use if everything else fails
     * @param defaultNames the default resource name(s)
     *
     * @return the library resource path
     *
     * @throws UnsatisfiedLinkError if the resource could not be found
     */
    public static Path load(Class<?> context, String module, Configuration<String> name, @Nullable Supplier<Path> fallback, String... defaultNames) {
        if (defaultNames.length == 0) {
            throw new IllegalArgumentException("No default names specified.");
        }

        String resourceName = name.get();
        if (resourceName != null) {
            return load(context, module, resourceName);
        }

        if (fallback == null && defaultNames.length <= 1) {
            return load(context, module, defaultNames[0]);
        }

        try {
            return load(context, module, defaultNames[0], false, false); // try first
        } catch (Throwable t) {
            for (int i = 1; i < defaultNames.length; i++) { // try alternatives
                try {
                    return load(context, module, defaultNames[i], false, fallback == null && i == defaultNames.length - 1);
                } catch (Throwable ignored) {
                }
            }
            if (fallback != null) {
                return fallback.get();
            }
            throw t; // original error
        }
    }

    private static void printError() {
        Library.printError(
            "[LWJGL] Failed to load a library resource. Possible solutions:\n" +
            "\ta) Add the directory that contains the resource to -Djava.library.path or -Dorg.lwjgl.librarypath.\n" +
            "\tb) Add the JAR that contains the resource to the classpath."
        );
    }

}


text:
import Raven from 'raven-js'

export const sentryUrl =
  'https://8c84076b24414cfe8295eee17e9e90a9@sentry.io/943062'

export function logException(ex, context) {
  Raven.captureException(ex, {
    extra: context
  })
  window && window.console && console.error && console.error(ex)
}


text:
title: Anymod.Vue
type: guide
order: 206
published: false
---

Anymod is built on top of [Vue.js version 2](https://vuejs.org), a lightweight JavaScript framework for building components. That means that any methods available in a Vue.js instance are available in all mods on Anymod.

## Accessing a mod instance

Calling `Anymod('_key_')` returns a Vue instance for a given mod. The Vue team typically refers to these instances as `vm` in their [documentation](https://vuejs.org/v2/api/#Instance-Properties).

```js
Anymod('orllm').text
// -> 'Foobar'
```

## Editing the JavaScript

In the dashboard JavaScript editor, you can access the mod instance with the `mod` keyword. For example, to add a method to a mod, you can enter the following into the JavaScript editor:

```JS
mod.methods = {
  sayHello: function () {
    console.log('Hello World!')
  }
}
```

In the HTML portion of the mod editor, you could call that method whenever a click occurs like so:

```HTML
<div @click="sayHello">Click me</div>
```

## Accessing the Vue library

If you want to use Vue.js alongside Anymod, you don't need to include both (though you can). The Anymod script automatically includes Vue.js, available globally as `Anymod.Vue`.

For example, you could create a new Vue instance like so:

```html
<div id="example"></div>
```
```js
new Anymod.Vue({
  el: '#example',
  data: { a: 1 }
})
```


text:
package org.apache.logging.log4j.core.appender.db;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.io.Serializable;

import org.apache.logging.log4j.core.LogEvent;
import org.junit.Test;

public class AbstractDatabaseManagerTest {
    // this stub is provided because mocking constructors is hard
    private static class StubDatabaseManager extends AbstractDatabaseManager {

        protected StubDatabaseManager(final String name, final int bufferSize) {
            super(name, bufferSize);
        }

        @Override
        protected boolean commitAndClose() {
            return true;
        }

        @Override
        protected void connectAndStart() {
            // noop
        }

        @Override
        protected boolean shutdownInternal() throws Exception {
            return true;
        }

        @Override
        protected void startupInternal() throws Exception {
            // noop
        }

        @Override
        protected void writeInternal(final LogEvent event, final Serializable serializable) {
            // noop
        }

    }

    private AbstractDatabaseManager manager;

    public void setUp(final String name, final int buffer) {
        manager = spy(new StubDatabaseManager(name, buffer));
    }

    @Test
    public void testBuffering01() throws Exception {
        setUp("name", 0);

        final LogEvent event1 = mock(LogEvent.class);
        final LogEvent event2 = mock(LogEvent.class);
        final LogEvent event3 = mock(LogEvent.class);

        manager.startup();
        then(manager).should().startupInternal();
        reset(manager);

        manager.write(event1, null);
        then(manager).should().writeThrough(same(event1), (Serializable) isNull());
        then(manager).should().connectAndStart();
        then(manager).should().isBuffered();
        then(manager).should().writeInternal(same(event1), (Serializable) isNull());
        then(manager).should().commitAndClose();
        then(manager).shouldHaveNoMoreInteractions();
        reset(manager);

        manager.write(event2, null);
        then(manager).should().writeThrough(same(event2), (Serializable) isNull());
        then(manager).should().connectAndStart();
        then(manager).should().isBuffered();
        then(manager).should().writeInternal(same(event2), (Serializable) isNull());
        then(manager).should().commitAndClose();
        then(manager).shouldHaveNoMoreInteractions();
        reset(manager);

        manager.write(event3, null);
        then(manager).should().writeThrough(same(event3), (Serializable) isNull());
        then(manager).should().connectAndStart();
        then(manager).should().isBuffered();
        then(manager).should().writeInternal(same(event3), (Serializable) isNull());
        then(manager).should().commitAndClose();
        then(manager).shouldHaveNoMoreInteractions();
        reset(manager);
    }

    @Test
    public void testBuffering02() throws Exception {
        setUp("name", 4);

        final LogEvent event1 = mock(LogEvent.class);
        final LogEvent event2 = mock(LogEvent.class);
        final LogEvent event3 = mock(LogEvent.class);
        final LogEvent event4 = mock(LogEvent.class);

        final LogEvent event1copy = mock(LogEvent.class);
        final LogEvent event2copy = mock(LogEvent.class);
        final LogEvent event3copy = mock(LogEvent.class);
        final LogEvent event4copy = mock(LogEvent.class);

        when(event1.toImmutable()).thenReturn(event1copy);
        when(event2.toImmutable()).thenReturn(event2copy);
        when(event3.toImmutable()).thenReturn(event3copy);
        when(event4.toImmutable()).thenReturn(event4copy);

        manager.startup();
        then(manager).should().startupInternal();

        manager.write(event1, null);
        manager.write(event2, null);
        manager.write(event3, null);
        manager.write(event4, null);

        then(manager).should().connectAndStart();
        verify(manager, times(5)).isBuffered(); // 4 + 1 in flush()
        then(manager).should().writeInternal(same(event1copy), (Serializable) isNull());
        then(manager).should().buffer(event1);
        then(manager).should().writeInternal(same(event2copy), (Serializable) isNull());
        then(manager).should().buffer(event2);
        then(manager).should().writeInternal(same(event3copy), (Serializable) isNull());
        then(manager).should().buffer(event3);
        then(manager).should().writeInternal(same(event4copy), (Serializable) isNull());
        then(manager).should().buffer(event4);
        then(manager).should().commitAndClose();
        then(manager).shouldHaveNoMoreInteractions();
    }

    @Test
    public void testBuffering03() throws Exception {
        setUp("name", 10);

        final LogEvent event1 = mock(LogEvent.class);
        final LogEvent event2 = mock(LogEvent.class);
        final LogEvent event3 = mock(LogEvent.class);

        final LogEvent event1copy = mock(LogEvent.class);
        final LogEvent event2copy = mock(LogEvent.class);
        final LogEvent event3copy = mock(LogEvent.class);

        when(event1.toImmutable()).thenReturn(event1copy);
        when(event2.toImmutable()).thenReturn(event2copy);
        when(event3.toImmutable()).thenReturn(event3copy);

        manager.startup();
        then(manager).should().startupInternal();

        manager.write(event1, null);
        manager.write(event2, null);
        manager.write(event3, null);
        manager.flush();

        then(manager).should().connectAndStart();
        verify(manager, times(4)).isBuffered();
        then(manager).should().writeInternal(same(event1copy), (Serializable) isNull());
        then(manager).should().buffer(event1);
        then(manager).should().writeInternal(same(event2copy), (Serializable) isNull());
        then(manager).should().buffer(event2);
        then(manager).should().writeInternal(same(event3copy), (Serializable) isNull());
        then(manager).should().buffer(event3);
        then(manager).should().commitAndClose();
        then(manager).shouldHaveNoMoreInteractions();
    }

    @Test
    public void testBuffering04() throws Exception {
        setUp("name", 10);

        final LogEvent event1 = mock(LogEvent.class);
        final LogEvent event2 = mock(LogEvent.class);
        final LogEvent event3 = mock(LogEvent.class);

        final LogEvent event1copy = mock(LogEvent.class);
        final LogEvent event2copy = mock(LogEvent.class);
        final LogEvent event3copy = mock(LogEvent.class);

        when(event1.toImmutable()).thenReturn(event1copy);
        when(event2.toImmutable()).thenReturn(event2copy);
        when(event3.toImmutable()).thenReturn(event3copy);

        manager.startup();
        then(manager).should().startupInternal();

        manager.write(event1, null);
        manager.write(event2, null);
        manager.write(event3, null);
        manager.shutdown();

        then(manager).should().connectAndStart();
        verify(manager, times(4)).isBuffered();
        then(manager).should().writeInternal(same(event1copy), (Serializable) isNull());
        then(manager).should().buffer(event1);
        then(manager).should().writeInternal(same(event2copy), (Serializable) isNull());
        then(manager).should().buffer(event2);
        then(manager).should().writeInternal(same(event3copy), (Serializable) isNull());
        then(manager).should().buffer(event3);
        then(manager).should().commitAndClose();
        then(manager).should().shutdownInternal();
        then(manager).shouldHaveNoMoreInteractions();
    }

    @Test
    public void testStartupShutdown01() throws Exception {
        setUp("testName01", 0);

        assertEquals("The name is not correct.", "testName01", manager.getName());
        assertFalse("The manager should not have started.", manager.isRunning());

        manager.startup();
        then(manager).should().startupInternal();
        assertTrue("The manager should be running now.", manager.isRunning());

        manager.shutdown();
        then(manager).should().shutdownInternal();
        assertFalse("The manager should not be running anymore.", manager.isRunning());
    }

    @Test
    public void testStartupShutdown02() throws Exception {
        setUp("anotherName02", 0);

        assertEquals("The name is not correct.", "anotherName02", manager.getName());
        assertFalse("The manager should not have started.", manager.isRunning());

        manager.startup();
        then(manager).should().startupInternal();
        assertTrue("The manager should be running now.", manager.isRunning());

        manager.releaseSub(-1, null);
        then(manager).should().shutdownInternal();
        assertFalse("The manager should not be running anymore.", manager.isRunning());
    }

    @Test
    public void testToString01() {
        setUp("someName01", 0);

        assertEquals("The string is not correct.", "someName01", manager.toString());
    }

    @Test
    public void testToString02() {
        setUp("bufferSize=12, anotherKey02=coolValue02", 12);

        assertEquals("The string is not correct.", "bufferSize=12, anotherKey02=coolValue02", manager.toString());
    }
}


text:
namespace {

#if defined(OS_LINUX) || defined(OS_CHROMEOS)
chromecast::CastCrashReporterClient* GetCastCrashReporter() {
  static base::NoDestructor<chromecast::CastCrashReporterClient>
      crash_reporter_client;
  return crash_reporter_client.get();
}
#endif  // defined(OS_LINUX) || defined(OS_CHROMEOS)

#if defined(OS_ANDROID)
const int kMaxCrashFiles = 10;
#endif  // defined(OS_ANDROID)

}  // namespace

namespace chromecast {
namespace shell {

CastMainDelegate::CastMainDelegate() {}

CastMainDelegate::~CastMainDelegate() {}

bool CastMainDelegate::BasicStartupComplete(int* exit_code) {
  RegisterPathProvider();

  logging::LoggingSettings settings;
  settings.logging_dest =
      logging::LOG_TO_SYSTEM_DEBUG_LOG | logging::LOG_TO_STDERR;

  const base::CommandLine* command_line(base::CommandLine::ForCurrentProcess());
  std::string process_type =
      command_line->GetSwitchValueASCII(switches::kProcessType);

  // Must be created outside of the if scope below to avoid lifetime concerns.
  std::string log_path_as_string;
  if (command_line->HasSwitch(switches::kLogFile)) {
    auto file_path = command_line->GetSwitchValuePath(switches::kLogFile);
    DCHECK(!file_path.empty());
    log_path_as_string = file_path.value();

    settings.logging_dest = logging::LOG_TO_ALL;
    settings.log_file_path = log_path_as_string.c_str();
    settings.lock_log = logging::DONT_LOCK_LOG_FILE;

    // If this is the browser process, delete the old log file. Else, append to
    // it.
    settings.delete_old = process_type.empty()
                              ? logging::DELETE_OLD_LOG_FILE
                              : logging::APPEND_TO_OLD_LOG_FILE;
  }

#if defined(OS_ANDROID)
  // Browser process logs are recorded for attaching with crash dumps.
  if (process_type.empty()) {
    base::FilePath log_file;
    base::PathService::Get(FILE_CAST_ANDROID_LOG, &log_file);
    settings.logging_dest =
        logging::LOG_TO_SYSTEM_DEBUG_LOG | logging::LOG_TO_STDERR;
    log_path_as_string = log_file.value();
    settings.log_file_path = log_path_as_string.c_str();
    settings.delete_old = logging::DELETE_OLD_LOG_FILE;
  }
#endif  // defined(OS_ANDROID)
  logging::InitLogging(settings);
#if BUILDFLAG(IS_CAST_DESKTOP_BUILD)
  logging::SetLogItems(true, true, true, false);
#else
  // Timestamp available through logcat -v time.
  logging::SetLogItems(true, true, false, false);
#endif  // BUILDFLAG(IS_CAST_DESKTOP_BUILD)

#if defined(OS_ANDROID)
  // Only delete the old crash dumps if the current process is the browser
  // process. Empty |process_type| signifies browser process.
  if (process_type.empty()) {
    // Get a listing of all of the crash dump files.
    base::FilePath crash_directory;
    if (CastCrashReporterClientAndroid::GetCrashReportsLocation(
            process_type, &crash_directory)) {
      base::FileEnumerator crash_directory_list(crash_directory, false,
                                                base::FileEnumerator::FILES);
      std::vector<base::FilePath> crash_files;
      for (base::FilePath file = crash_directory_list.Next(); !file.empty();
           file = crash_directory_list.Next()) {
        crash_files.push_back(file);
      }
      // Delete crash dumps except for the |kMaxCrashFiles| most recent ones.
      if (crash_files.size() > kMaxCrashFiles) {
        auto newest_first =
            [](const base::FilePath& l, const base::FilePath& r) -> bool {
              base::File::Info l_info, r_info;
              base::GetFileInfo(l, &l_info);
              base::GetFileInfo(r, &r_info);
              return l_info.last_modified > r_info.last_modified;
            };
        std::partial_sort(crash_files.begin(),
                          crash_files.begin() + kMaxCrashFiles,
                          crash_files.end(), newest_first);
        for (auto file = crash_files.begin() + kMaxCrashFiles;
             file != crash_files.end(); ++file) {
          base::DeleteFile(*file);
        }
      }
    }
  }
#endif  // defined(OS_ANDROID)

  if (settings.logging_dest & logging::LOG_TO_FILE) {
    LOG(INFO) << "Logging to file: " << settings.log_file_path;
  }
  return false;
}

void CastMainDelegate::PreSandboxStartup() {
#if defined(ARCH_CPU_ARM_FAMILY) && \
    (defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS))
  // Create an instance of the CPU class to parse /proc/cpuinfo and cache the
  // results. This data needs to be cached when file-reading is still allowed,
  // since base::CPU expects to be callable later, when file-reading is no
  // longer allowed.
  base::CPU cpu_info;
#endif

  const base::CommandLine* command_line(base::CommandLine::ForCurrentProcess());
  std::string process_type =
      command_line->GetSwitchValueASCII(switches::kProcessType);

  bool enable_crash_reporter = !command_line->HasSwitch(
      switches::kDisableCrashReporter);
  if (enable_crash_reporter) {
    // TODO(crbug.com/1226159): Complete crash reporting integration on Fuchsia.
#if defined(OS_ANDROID)
    base::FilePath log_file;
    base::PathService::Get(FILE_CAST_ANDROID_LOG, &log_file);
    chromecast::CrashHandler::Initialize(process_type, log_file);
#elif defined(OS_LINUX) || defined(OS_CHROMEOS)
  crash_reporter::SetCrashReporterClient(GetCastCrashReporter());

  if (process_type != switches::kZygoteProcess) {
    CastCrashReporterClient::InitCrashReporter(process_type);
  }
#endif  // defined(OS_LINUX) || defined(OS_CHROMEOS)

    crash_reporter::InitializeCrashKeys();
  }

  InitializeResourceBundle();
}

absl::variant<int, content::MainFunctionParams> CastMainDelegate::RunProcess(
    const std::string& process_type,
    content::MainFunctionParams main_function_params) {
#if defined(OS_ANDROID)
  if (!process_type.empty())
    return std::move(main_function_params);

  // Note: Android must handle running its own browser process.
  // See ChromeMainDelegateAndroid::RunProcess.
  browser_runner_ = content::BrowserMainRunner::Create();
  int exit_code = browser_runner_->Initialize(std::move(main_function_params));
  // On Android we do not run BrowserMain(), so the above initialization of a
  // BrowserMainRunner is all we want to occur. Preserve any error codes > 0.
  if (exit_code > 0)
    return exit_code;
  return 0;
#else
  return std::move(main_function_params);
#endif  // defined(OS_ANDROID)
}

#if defined(OS_LINUX) || defined(OS_CHROMEOS)
void CastMainDelegate::ZygoteForked() {
  const base::CommandLine* command_line(base::CommandLine::ForCurrentProcess());
  bool enable_crash_reporter = !command_line->HasSwitch(
      switches::kDisableCrashReporter);
  if (enable_crash_reporter) {
    std::string process_type =
        command_line->GetSwitchValueASCII(switches::kProcessType);
    CastCrashReporterClient::InitCrashReporter(process_type);
  }
}
#endif  // defined(OS_LINUX) || defined(OS_CHROMEOS)

bool CastMainDelegate::ShouldCreateFeatureList() {
  return false;
}

void CastMainDelegate::PostEarlyInitialization(bool is_running_tests) {
  DCHECK(cast_feature_list_creator_);

#if !defined(OS_ANDROID)
  // PrefService requires the home directory to be created before the pref store
  // can be initialized properly.
  base::FilePath home_dir;
  CHECK(base::PathService::Get(DIR_CAST_HOME, &home_dir));
  CHECK(base::CreateDirectory(home_dir));
#endif  // !defined(OS_ANDROID)

  // TODO(crbug/1249485): If we're able to create the MetricsStateManager
  // earlier, clean up the below if and else blocks and call
  // MetricsStateManager::InstantiateFieldTrialList().
  //
  // The FieldTrialList is a dependency of the feature list. In tests, it is
  // constructed as part of the test suite.
  if (is_running_tests) {
    DCHECK(base::FieldTrialList::GetInstance());
  } else {
    // This is intentionally leaked since it needs to live for the duration of
    // the browser process and there's no benefit to cleaning it up at exit.
    base::FieldTrialList* leaked_field_trial_list =
        new base::FieldTrialList(nullptr);
    ANNOTATE_LEAKING_OBJECT_PTR(leaked_field_trial_list);
    ignore_result(leaked_field_trial_list);
  }

  // Initialize the base::FeatureList and the PrefService (which it depends on),
  // so objects initialized after this point can use features from
  // base::FeatureList.
  cast_feature_list_creator_->CreatePrefServiceAndFeatureList();
}

void CastMainDelegate::InitializeResourceBundle() {
  base::FilePath pak_file;
  CHECK(base::PathService::Get(FILE_CAST_PAK, &pak_file));
#if defined(OS_ANDROID)
  // On Android, the renderer runs with a different UID and can never access
  // the file system. Use the file descriptor passed in at launch time.
  auto* global_descriptors = base::GlobalDescriptors::GetInstance();
  int pak_fd = global_descriptors->MaybeGet(kAndroidPakDescriptor);
  base::MemoryMappedFile::Region pak_region;
  if (pak_fd >= 0) {
    pak_region = global_descriptors->GetRegion(kAndroidPakDescriptor);

    base::File android_pak_file(pak_fd);
    ui::ResourceBundle::InitSharedInstanceWithPakFileRegion(
        android_pak_file.Duplicate(), pak_region);
    ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion(
        std::move(android_pak_file), pak_region, ui::k100Percent);
    return;
  } else {
    pak_fd = base::android::OpenApkAsset("assets/cast_shell.pak", &pak_region);
    // Loaded from disk for browsertests.
    if (pak_fd < 0) {
      int flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
      pak_fd = base::File(pak_file, flags).TakePlatformFile();
      pak_region = base::MemoryMappedFile::Region::kWholeFile;
    }
    DCHECK_GE(pak_fd, 0);
    global_descriptors->Set(kAndroidPakDescriptor, pak_fd, pak_region);
  }

  ui::SetLocalePaksStoredInApk(true);
#endif  // defined(OS_ANDROID)

  resource_delegate_.reset(new CastResourceDelegate());
  // TODO(gunsch): Use LOAD_COMMON_RESOURCES once ResourceBundle no longer
  // hardcodes resource file names.
  ui::ResourceBundle::InitSharedInstanceWithLocale(
      "en-US", resource_delegate_.get(),
      ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);

#if defined(OS_ANDROID)
  ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion(
      base::File(pak_fd), pak_region, ui::kScaleFactorNone);
#else
  ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
      pak_file, ui::kScaleFactorNone);
#endif  // defined(OS_ANDROID)
}

content::ContentClient* CastMainDelegate::CreateContentClient() {
  return &content_client_;
}

content::ContentBrowserClient* CastMainDelegate::CreateContentBrowserClient() {
  DCHECK(!cast_feature_list_creator_);
  cast_feature_list_creator_ = std::make_unique<CastFeatureListCreator>();
  browser_client_ =
      CastContentBrowserClient::Create(cast_feature_list_creator_.get());
  return browser_client_.get();
}

content::ContentGpuClient* CastMainDelegate::CreateContentGpuClient() {
  gpu_client_ = CastContentGpuClient::Create();
  return gpu_client_.get();
}

content::ContentRendererClient*
CastMainDelegate::CreateContentRendererClient() {
  renderer_client_ = CastContentRendererClient::Create();
  return renderer_client_.get();
}

content::ContentUtilityClient* CastMainDelegate::CreateContentUtilityClient() {
  utility_client_ = CastContentUtilityClient::Create();
  return utility_client_.get();
}

}  // namespace shell
}  // namespace chromecast


text:
using System;
using System.Collections.Generic;
using Umbraco.Cms.Core.Models.Entities;

namespace Umbraco.Cms.Core.Models.Membership
{

    /// <summary>
    /// Defines the interface for a <see cref="User"/>
    /// </summary>
    /// <remarks>Will be left internal until a proper Membership implementation is part of the roadmap</remarks>
    public interface IUser : IMembershipUser, IRememberBeingDirty, ICanBeDirty
    {
        UserState UserState { get; }

        string? Name { get; set; }
        int SessionTimeout { get; set; }
        int[]? StartContentIds { get; set; }
        int[]? StartMediaIds { get; set; }
        string? Language { get; set; }

        DateTime? InvitedDate { get; set; }

        /// <summary>
        /// Gets the groups that user is part of
        /// </summary>
        IEnumerable<IReadOnlyUserGroup> Groups { get; }

        void RemoveGroup(string group);
        void ClearGroups();
        void AddGroup(IReadOnlyUserGroup group);

        IEnumerable<string> AllowedSections { get; }

        /// <summary>
        /// Exposes the basic profile data
        /// </summary>
        IProfile ProfileData { get; }

        /// <summary>
        /// Will hold the media file system relative path of the users custom avatar if they uploaded one
        /// </summary>
        string? Avatar { get; set; }

        /// <summary>
        /// A Json blob stored for recording tour data for a user
        /// </summary>
        string? TourData { get; set; }
    }
}


text:
package org.testng.reporters.jq;

import org.testng.ISuite;

/** Panels that are accessible from the navigator. */
public interface INavigatorPanel extends IPanel {
  String getPanelName(ISuite suite);

  String getNavigatorLink(ISuite suite);

  String getClassName();

  String getPrefix();
}


text:
//
//  BallSprite.cpp
//  TumTum_Base
//
//  Created by ohtaisao on 2014/12/11.
//
//

#include "BallSprite.h"

BallSprite *BallSprite::createBallSprite(Node *parent ,b2World *world, const std::string& filename)
{
    BallSprite* pInstance = BallSprite::create();

    //Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename);

    pInstance->setTexture(filename);

    // shape.m_radius = sptite->getContentSize().width / PTM_RATIO; // 形状の大きさ

    /**
     *
     剛体は次の手順で作成する。剛体とは物理エンジンの影響をうけることが出来る物質のこと

     1. 位置・減衰率などで剛体を定義する。
     2. 剛体を作成するためにワールドを使用する。
     3. 図形・摩擦・密度などから装備を定義する。
     4. 剛体から装備を作成する。
     */
    b2Body* body; // 剛体。rigid body。
    b2BodyDef bodyDef; // 剛体の定義
    b2CircleShape shape; // 装備の形状
    float radius = getBallRadius();
    shape.m_radius = radius/ PTM_RATIO;;
    b2FixtureDef fixtureDef; // 装備の形状定義

    // 1. 位置・減衰率などで剛体を定義する。
    bodyDef.type = b2_dynamicBody;
    //bodyDef.position.Set((winSize.width / 2) / PTM_RATIO, (winSize.height) / PTM_RATIO);
    bodyDef.userData = pInstance; // 画像をこの剛体に紐付ける

    // 2. 剛体を作成するためにワールドを使用する。
    body = world->CreateBody(&bodyDef);

    fixtureDef.shape = &shape; // 形状を紐付ける
    fixtureDef.density = 1; // 密度
    fixtureDef.friction = 0.9; // 摩擦

    // 4. 剛体から装備を作成する。
    body->CreateFixture(&fixtureDef);

    /** PhysicsSpriteに各種情報をセットする */
    //parent->addChild(pInstance);
    pInstance->setB2Body(body);
    pInstance->setPTMRatio(PTM_RATIO);

    parent->addChild(pInstance);

    return pInstance;
}

BallSprite *BallSprite::createParticleSprite(Node *parent ,b2World *world, const std::string& filename) {
    BallSprite* pInstance = BallSprite::create();

    //Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename);

    pInstance->setTexture(filename);

    //パーティクルシステムのデータ設定
    b2ParticleSystemDef particleSystemDef;

    //各パーティクルの半径を設定
    particleSystemDef.radius =  getBallRadius();

    //パーティクルシステムの生成
    b2ParticleSystem * particleSystem = world->CreateParticleSystem(&particleSystemDef);
    void ** userData = particleSystem->GetUserDataBuffer();
    (*userData) = pInstance;
    parent->addChild(pInstance);
    return pInstance;

    //画面サイズ取得
    //Size size = Director::getInstance()->getWinSize();

    //生成位置設定
    //Point pos = {size.width/2/PTM_RATIO,size.height * 0.2/PTM_RATIO};

    //グループで生成する際はパーティクルグループの形を設定する必要がある
    //b2PolygonShape* shape = new b2PolygonShape();
    //shape->SetAsBox(size.width*0.8/PTM_RATIO, size.height*0.05/PTM_RATIO);

    //パーティクルグループのデータ設定
    //b2ParticleGroupDef groupDef;

    //パーティクルのグループを設定
   // groupDef.shape = shape;

    //flagsを設定する事でパーティクルの挙動を設定する事ができます
    //今回は海を作るので水になっていますが
    //バネや砂など色々な挙動を設定する事ができます。
   // groupDef.flags = b2_waterParticle;
    //groupDef.color = b2ParticleColor(100,150,255,255);
    //groupDef.position.Set(pos.x / PTM_RATIO, pos.y / PTM_RATIO);
    //seaGroup = particleSystem->CreateParticleGroup(groupDef);

    //各パーティクルのユーザーデータに「Sprite*」を持たせる
    //ユーザーデータは「b2ParticleSystem」がバッファとして保持している。
    //各グループはデータの開始地点を保持しており
    //自分のグループが保持しているパーティクルの分だけループして取得する事ができる
    /*
    void ** userData = particleSystem->GetUserDataBuffer() + seaGroup->GetBufferIndex();
    for(int i = 0; i != seaGroup->GetParticleCount();i++,userData++){
        Sprite * tex = Sprite::create("tex.png");
        (*userData) = tex;
        tex->setScale(0.5f);
        this->addChild(tex);
    }
     */
}

void BallSprite::setPhysics2Sprite(b2World *world, cocos2d::extension::PhysicsSprite *sptite, b2BodyType type, b2Shape shape)
{
    /**
     *
     剛体は次の手順で作成する。剛体とは物理エンジンの影響をうけることが出来る物質のこと

     1. 位置・減衰率などで剛体を定義する。
     2. 剛体を作成するためにワールドを使用する。
     3. 図形・摩擦・密度などから装備を定義する。
     4. 剛体から装備を作成する。
     */
    b2Body* body; // 剛体。rigid body。
    b2BodyDef bodyDef; // 剛体の定義
    //b2CircleShape shape; // 装備の形状
    b2FixtureDef fixtureDef; // 装備の形状定義

    // 1. 位置・減衰率などで剛体を定義する。
    bodyDef.type = type;
    //bodyDef.position.Set((winSize.width / 2) / PTM_RATIO, (winSize.height) / PTM_RATIO);
    bodyDef.userData = sptite; // 画像をこの剛体に紐付ける

    // 2. 剛体を作成するためにワールドを使用する。
    body = world->CreateBody(&bodyDef);

    fixtureDef.shape = &shape; // 形状を紐付ける
    fixtureDef.density = 1; // 密度
    fixtureDef.friction = 0.9; // 摩擦

    // 4. 剛体から装備を作成する。
    body->CreateFixture(&fixtureDef);

    /** PhysicsSpriteに各種情報をセットする */
    //parent->addChild(pInstance);
    sptite->setB2Body(body);
    sptite->setPTMRatio(PTM_RATIO);

}

float BallSprite::getBallRadius()
{

    return 50;
}

bool BallSprite::init()
{
    if ( !Sprite::init() ) {
        return false;
    }
    _ballContactState = ballContactState::kNone;
    _deleteState      = deleteState::kNoDelete;
    _ballType         = ballType::kRed;
    _ballHilightType  = ballHilightType::kNoTouch;

    _isTouchBegan = false;
    _isTouchMoved = false;
    _isTouchEnd   = false;

    this->setOpacity(200);
    return true;
}

BallSprite::ballContactState BallSprite::getBallContState(){

    return _ballContactState;
}

void BallSprite::setBallContState(ballContactState state) {
    if (state == ballContactState::kFloorContact || ballContactState::kSecondContact) {
        //cpSpaceAddPostStepCallback
        //body->setDynamic(false);
        Vec2 ver = Vec2(0, 0.1);
        //body->setVelocity(ver);
    }
    else {
        //body->setDynamic(true);
    }
    _ballContactState = state;
}

bool BallSprite::isInCircle(Vec2 pos, Node *parent) {
    const Vec2 bpos = parent->convertToNodeSpace(this->getPosition());
    float dist = pos.getDistance(bpos);
    if(dist <= getBallRadius()) {
        return true;
    }
    else {
        return false;
    }
}

bool BallSprite::isInCircle(Touch touch) {
    const Vec2 bpos = this->getPosition();
    Director* pDirector = CCDirector::getInstance();
    Point touchPoint = pDirector -> convertToGL(touch.getLocationInView());
    float dist = touchPoint.getDistance(bpos);
    if(dist <= getBallRadius()) {
        return true;
    }
    else {
        return false;
    }

}

bool BallSprite::getIsTouchBegan() {
    return _isTouchBegan;
}
void BallSprite::setIsTouchBegan() {
    _isTouchBegan = true;
}
bool BallSprite::getIsTouchMoved() {
    return _isTouchMoved;
}
void BallSprite::setIsTouchMoved() {
    _isTouchMoved = true;
}
bool BallSprite::getIsTouchEnd() {
    return _isTouchEnd;
}
void BallSprite::setIsTouchEnd() {
    _isTouchEnd = true;
}

BallSprite::deleteState BallSprite::getDeleteState() {

    return _deleteState;
}

void BallSprite::setDeleteState(deleteState state){
    _deleteState = state;
}

BallSprite::ballType BallSprite::getBallType() {
    return _ballType;
}

void BallSprite::setBallType(ballType state) {
    _ballType = state;
}

BallSprite::ballHilightType BallSprite::getBallHilightType() {
    return _ballHilightType;
}
void BallSprite::setBallHilightType(ballHilightType state) {
    _ballHilightType = state;
    if (state ==  ballHilightType::kNoTouch) {
        this->setOpacity(200);
        this->setNormalTexture();
    }
    else if (state == ballHilightType::kTouch) {
        this->setOpacity(200);
        this->setNormalTexture();
    }
    else if (state == ballHilightType::kFirstTouch) {
        this->setOpacity(200);
        this->setNormalTexture();
    }
    else if (state == ballHilightType::kChain) {
        this->setOpacity(150);
        this->setHilightTexture();

    }
    else if (state == ballHilightType::kAdjacent) {
        this->setOpacity(255);
        this->setHilightTexture();
    }
    else {
        this->setOpacity(200);
        this->setNormalTexture();
    }
}

void BallSprite::setNormalTexture() {
    ballType type = this->getBallType();
    switch (type) {
        case ballType::kRed:
            this->setTexture(Director::getInstance()->getTextureCache()->addImage("ball.png"));
            break;
        case ballType::kBrue:
            this->setTexture(Director::getInstance()->getTextureCache()->addImage("blue_ball.png"));
            break;
        case ballType::kYellow:
            this->setTexture(Director::getInstance()->getTextureCache()->addImage("yellow_ball.png"));
            break;
        case ballType::kPurple:
            this->setTexture(Director::getInstance()->getTextureCache()->addImage("pur_ball.png"));
            break;
        default:
            this->setTexture(Director::getInstance()->getTextureCache()->addImage("ball.png"));
            break;
    }

}
void BallSprite::setHilightTexture() {
    ballType type = this->getBallType();
    switch (type) {
        case ballType::kRed:
            this->setTexture(Director::getInstance()->getTextureCache()->addImage("hl_ball.png"));
            break;
        case ballType::kBrue:
            this->setTexture(Director::getInstance()->getTextureCache()->addImage("hl_blue_ball.png"));
            break;
        case ballType::kYellow:
            this->setTexture(Director::getInstance()->getTextureCache()->addImage("hl_yellow_ball.png"));
            break;
        case ballType::kPurple:
            this->setTexture(Director::getInstance()->getTextureCache()->addImage("hl_pur_ball.png"));
            break;
        default:
            this->setTexture(Director::getInstance()->getTextureCache()->addImage("hl_ball.png"));
            break;
    }
}


text:
#include "Controller Move Result.h"

using namespace StillDesign::PhysX;

ControllerMoveResult::ControllerMoveResult( ControllerCollisionFlag collision )
{
	_collision = collision;
}

ControllerCollisionFlag ControllerMoveResult::CollisionFlag::get()
{
	return _collision;
}