*ignore* How to check if an Array<string> contains an item that starts with a value

时间:2015-05-08 09:54:20

标签: java arrays

The app fetches data from a server. The data is returned in an Array. I need to check if one of the Array items starts with a value specified in the app. If it's possible without iterating because that slows down the app significantly.

1 个答案:

答案 0 :(得分:2)

If you have just an array data structure, there is no way to check what it contains without actually looking into it.

However if you use a different data structure such as a HashMap (which is built on to of an array) you can check/lookup a key like Client: Open a popup window via $auth.authenticate('provider name'). Client: Unlike OAuth 2.0, you cannot go directly to the authentication screen without a valid request token. Client: The OAuth 1.0 flow starts with the GET request to /auth/provider inside the popup. Server: Check if URL contains oauth_token and oauth_verifier parameters. Sever: Initially it does not, so send an OAuth signed POST request to the /request_token URL. Server: Redirect to the /authenticate URL with a valid request token. in O(1) time typically. You can check No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin is therefore not allowed access. in O(1) time.

In short, if it's taking too long to perform a simple operation, chances are you need to be using a different data structure (or possibly more than one)