On February 01 2019 18:39 ahswtini wrote:
daily reminder to say no to epic games store
daily reminder to say no to epic games store
I don't have time for metro anyway
| Forum Index > Dota 2 General |
|
Artisreal
Germany9235 Posts
February 01 2019 13:04 GMT
#198881
On February 01 2019 18:39 ahswtini wrote: daily reminder to say no to epic games store I don't have time for metro anyway | ||
|
teddyoojo
Germany22369 Posts
February 01 2019 13:25 GMT
#198882
+ Show Spoiler + public static int smallest(int[] array) { int[] clone = array; Arrays.sort(clone); return clone[0]; } public static int indexOfTheSmallest(int[] array) { int i = smallest(array); for(int j = 0; j < array.length; j++) { if(array[j] == i) { return j; } } return -1; } | ||
|
intotheheart
Canada33091 Posts
February 01 2019 14:57 GMT
#198883
On February 01 2019 01:31 ahswtini wrote: im surprised everyone isnt playing LANGRISSER I want to, the Facebook ads look pretty great honestly. But I don't wanna take attention away from Azur Lane, you know? Teddy I think what happens when you use int[] clone = array, you copy the memory reference instead of the array values, such that any changes to clone will affect array since they change the same address in memory. If you want to just clone the values, you should use int []clone = array.clone() instead which will copy all the values. https://www.geeksforgeeks.org/array-copy-in-java/ | ||
|
Nevuk
United States16280 Posts
February 01 2019 15:07 GMT
#198884
| ||
|
teddyoojo
Germany22369 Posts
February 01 2019 15:57 GMT
#198885
On February 01 2019 23:57 intotheheart wrote: Show nested quote + On February 01 2019 01:31 ahswtini wrote: im surprised everyone isnt playing LANGRISSER I want to, the Facebook ads look pretty great honestly. But I don't wanna take attention away from Azur Lane, you know? Teddy I think what happens when you use int[] clone = array, you copy the memory reference instead of the array values, such that any changes to clone will affect array since they change the same address in memory. If you want to just clone the values, you should use int []clone = array.clone() instead which will copy all the values. https://www.geeksforgeeks.org/array-copy-in-java/ thanks, this worked of course(i just hadnt realized u cant copy arrays like that): for (int i=0; i<a.length; i++) b[i] = a[i]; | ||
|
PoulsenB
Poland7754 Posts
February 01 2019 16:09 GMT
#198886
feelsbad | ||
|
Unleashing
Denmark14978 Posts
February 01 2019 16:11 GMT
#198887
But I found a job in the field I care about, so that's nice. | ||
|
intotheheart
Canada33091 Posts
February 01 2019 16:27 GMT
#198888
| ||
|
PhoenixVoid
Canada32755 Posts
February 01 2019 16:51 GMT
#198889
On February 02 2019 01:09 PoulsenB wrote: Every time someone discusses coding I regret studying philology instead of sciences/engineering feelsbad Not too late to learn a language. I empathize with your situation as a fellow non-STEM major. I think I might have to start very soon, given that I might have to look into being a technical writer and nowadays 90% of jobs in that field demand at least knowledge in one programming language. | ||
|
Erasme
Bahamas15899 Posts
February 01 2019 17:06 GMT
#198890
On February 02 2019 00:07 Nevuk wrote: I've run into a situation where declaring a new array didn't even clear the array and resulted in a somewhat hilarious situation of adding the entire array to itself recursively. Had to use array.clear() , Java can be dumb. you got some memory issues i dont see how if you declare a new array, you still get the old one in java unless you don't use 'new' | ||
|
teddyoojo
Germany22369 Posts
February 01 2019 17:48 GMT
#198891
is there a better way to write this? seems ugly + Show Spoiler + public static void swap(int[] array, int index1, int index2) { // int var1 = index1; // int var2 = index2; int var3 = array[index1]; int var4 = array[index2]; array[index1] = var4; array[index2] = var3; } lol nvm i commented out the obviously irrelevant part now, doesnt look too wrong anymore | ||
|
Slomo
Germany7198 Posts
February 01 2019 18:22 GMT
#198892
In pseudocode a = 1 b = 2 c = b b = a a = c Adapt it to your Java needs. | ||
|
Nevuk
United States16280 Posts
February 01 2019 18:35 GMT
#198893
On February 02 2019 02:06 Erasme wrote: Show nested quote + On February 02 2019 00:07 Nevuk wrote: I've run into a situation where declaring a new array didn't even clear the array and resulted in a somewhat hilarious situation of adding the entire array to itself recursively. Had to use array.clear() , Java can be dumb. you got some memory issues i dont see how if you declare a new array, you still get the old one in java unless you don't use 'new' I checked , it was a local list variable actually. Nw= new arraylist Path.filter.Foreachorderered ->{ List p = methodthatreturnsobject Nw.add(p) p.clear } Shitty pseudo code because I'm on mobile, but that should give you the idea. If I didn't add clear then it just recursively added to itself. | ||
|
Erasme
Bahamas15899 Posts
February 01 2019 18:52 GMT
#198894
On February 02 2019 03:35 Nevuk wrote: Show nested quote + On February 02 2019 02:06 Erasme wrote: On February 02 2019 00:07 Nevuk wrote: I've run into a situation where declaring a new array didn't even clear the array and resulted in a somewhat hilarious situation of adding the entire array to itself recursively. Had to use array.clear() , Java can be dumb. you got some memory issues i dont see how if you declare a new array, you still get the old one in java unless you don't use 'new' I checked , it was a local list variable actually. Nw= new arraylist Path.filter.Foreachorderered ->{ List p = methodthatreturnsobject Nw.add(p) p.clear } Shitty pseudo code because I'm on mobile, but that should give you the idea. If I didn't add clear then it just recursively added to itself. so you'd end up with something like a aab aababc ? lmao | ||
|
CorsairHero
Canada9491 Posts
February 01 2019 19:28 GMT
#198895
On February 02 2019 00:57 teddyoojo wrote: Show nested quote + On February 01 2019 23:57 intotheheart wrote: On February 01 2019 01:31 ahswtini wrote: im surprised everyone isnt playing LANGRISSER I want to, the Facebook ads look pretty great honestly. But I don't wanna take attention away from Azur Lane, you know? Teddy I think what happens when you use int[] clone = array, you copy the memory reference instead of the array values, such that any changes to clone will affect array since they change the same address in memory. If you want to just clone the values, you should use int []clone = array.clone() instead which will copy all the values. https://www.geeksforgeeks.org/array-copy-in-java/ thanks, this worked of course(i just hadnt realized u cant copy arrays like that): for (int i=0; i<a.length; i++) b[i] = a[i]; please use memcpy or the equivalent function thx | ||
|
teddyoojo
Germany22369 Posts
February 01 2019 19:39 GMT
#198896
| ||
|
Erasme
Bahamas15899 Posts
February 01 2019 19:54 GMT
#198897
| ||
|
Erasme
Bahamas15899 Posts
February 01 2019 19:55 GMT
#198898
On February 02 2019 04:54 Erasme wrote: http://manpagesfr.free.fr/man/man3/memcpy.3.html "=" doesn't work everytime wops | ||
|
CorsairHero
Canada9491 Posts
February 01 2019 20:13 GMT
#198899
On February 01 2019 18:39 ahswtini wrote: daily reminder to say no to epic games store whats wrong with it | ||
|
intotheheart
Canada33091 Posts
February 01 2019 20:20 GMT
#198900
I think that Erasme's saying that you may find that using certain array methods like clone() to be more practical when you have larger data structures, but there's nothing wrong with just copying things over one at a time when you're doing ints. | ||
| ||
StarCraft 2 StarCraft: Brood War Shuttle Dota 2Soma BeSt Soulkey Snow Rush hero Barracks Sea.KH Hyun [ Show more ] Sharp Pusan Liquid`Ret Dewaltoss 910 zelot Rock soO Free IntoTheRainbow ajuk12(nOOB) Terrorterran NaDa SilentControl Counter-Strike Super Smash Bros Other Games Gorgc4354 B2W.Neo1086 hiko1051 Liquid`RaSZi976 Beastyqt696 fl0m519 crisheroes398 ToD193 Liquid`VortiX153 ArmadaUGS139 KnowMe94 Chillindude81 QueenE68 UpATreeSC42 Trikslyr37 |
|
PiGosaur Cup
Afreeca Starleague
Mini vs Calm
Queen vs EffOrt
Replay Cast
The PondCast
Replay Cast
Escore
IntoTheTV X SOOP
Korean StarCraft League
GSL
Replay Cast
[ Show More ] Sparkling Tuna Cup
WardiTV Weekly
GSL
|
|
|