Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Tutorial: How to walk a path in one line of code

Featured Replies

For an array A where:

 

Position A[0] = x

Position A[1]  = y

Position A[2] = z

 

And an empty array B with size 3.

 

Array B after your method:

 

Position B[2] = A[2]

Position B[1] = A[1]

Position B[0] = A[0]

 

->

 

B[0] = A[0] = x

B[1] = A[1] = y

B[2] = B[2] = z

 

A = B 

 

Is that actually necessary?

I was under the impression that they wanted to generate a path that was simply progressing in the opposite direction.

Is that actually necessary?

I was under the impression that they wanted to generate a path that was simply progressing in the opposite direction.

 

I don't think you understand what we are saying.  Your method literally just returns the exact same order of the path that you pass to it. No change what so ever.

I don't think you understand what we are saying.  Your method literally just returns the exact same order of the path that you pass to it. No change what so ever.

 

Huh, looks like I spaced out there.

I fixed the method I provided, it works now.

Huh, looks like I spaced out there.

I fixed the method I provided, it works now.

 

Still is an inefficient way to do it, but it should work now at least. :p

Still is an inefficient way to do it, but it should work now at least. tongue.png

 

He asked how, not how to do it the most efficiently.


public <T> void reverse(T[] array) {

for(int i = 0; i < array.length >> 1; i++) {

T tmp = array;

array = array[array.length - 1 - i];

array[array.length - 1 - i] = tmp;

}

}

public <T> void reverse(T[] array) {
	for(int i = 0; i < array.length >> 1; i++) {
		T tmp = array[i];
		array[i] = array[array.length - 1 - i];
		array[array.length - 1 - i] = tmp;
	}
}

 

Any reason why you use a generic instead of an object parameter?

Is it a casting thing?

public <T> void reverse(T[] array) {
	for(int i = 0; i < array.length >> 1; i++) {
		T tmp = array[i];
		array[i] = array[array.length - 1 - i];
		array[array.length - 1 - i] = tmp;
	}
}

 

 

At least someone gets it :P

Any reason why you use a generic instead of an object parameter?

Is it a casting thing?

 

 

Because now the array can be of any type.

Look into:

Collections.reverse()

Why not this above? Convert your array into a list. With Arrays#asList(array) then use the Collections#reverse (list)

Edited by josedpay

 Convert your array into a list. 

 

If you have to convert it then its not going to be as efficient.

 

i.e. take more memory and time.

Edited by Mysteryy

so If I wanted to walk to some location, and also walk from that location to my starting location, I would need to set up two paths?

so If I wanted to walk to some location, and also walk from that location to my starting location, I would need to set up two paths?

 

Hey man, the reason there was a discussion on reversing a path was that you can use a path to get somewhere and then simply reverse it to return

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.