Reversing an Array - Use Cases

  • (2 Pages)
  • +
  • 1
  • 2

24 Replies - 892 Views - Last Post: 24 September 2013 - 02:39 PM Rate Topic: -----

#16 Atspulgs  Icon User is offline

  • D.I.C Regular

Reputation: 68
  • View blog
  • Posts: 380
  • Joined: 29-July 09

Re: Reversing an Array - Use Cases

Posted 24 September 2013 - 11:41 AM

A bit off topic here but,

Whats '<T>' in 'public class ReverseList<T> implements List<T>' called? Can you point me to a good explanation of whatever that really is?
I was never taught of it and searching for <T> is kindof... problematic without knowing the name :D
Was This Post Helpful? 0
  • +
  • -

#17 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10440
  • View blog
  • Posts: 38,668
  • Joined: 27-December 08

Re: Reversing an Array - Use Cases

Posted 24 September 2013 - 11:49 AM

These are called Generics. Some links:

The Evolution of Generic Programming in Java
Tutoracles on Generics
Was This Post Helpful? 3
  • +
  • -

#18 Atspulgs  Icon User is offline

  • D.I.C Regular

Reputation: 68
  • View blog
  • Posts: 380
  • Joined: 29-July 09

Re: Reversing an Array - Use Cases

Posted 24 September 2013 - 11:51 AM

-Epic holy sound-

Thank you! This would have given me nightmares now that the curiosity peeked its nasty head :D
Was This Post Helpful? 0
  • +
  • -

#19 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2251
  • View blog
  • Posts: 9,433
  • Joined: 29-May 08

Re: Reversing an Array - Use Cases

Posted 24 September 2013 - 12:11 PM

XOR swap is useful in some assembly programming in situations where register usage is limited. In ARM code it takes the same number of instructions.

; Using an additional register
MOV tmpR, regA
MOV regA, regB
MOV regB, tmpR
; without using a temporary
EOR regA, regA, regB
EOR regB, regA, regB
EOR regA, regA, regB


Was This Post Helpful? 1
  • +
  • -

#20 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7621
  • View blog
  • Posts: 12,849
  • Joined: 19-March 11

Re: Reversing an Array - Use Cases

Posted 24 September 2013 - 01:17 PM

View Postcfoley, on 24 September 2013 - 11:47 AM, said:

Quote

Since DNA strings are not inherently directed


I wouldn't be so sure about that...


To be more precise: a DNA string in situ is directed. The one you find in the lab, you don't know which direction it was going, because all you get is a string of amino acids - or am I mistaken on this? I could very well be.
(To be honest, much of my understanding of DNA strings comes from solving problems at rosalind.info - my last biology class was in high school, which was a few years ago)

Quote

And on OO land, we tend to shun arrays in favour of lists. How do you reverse a list? You call Collections.reverse(), or course.


True. And to sort, you call the library sort() routine, and to encrypt something you use a cryptography package that is both open and well-tested in the wild. You would not want to stop what you're doing to write a sort in your daily work, and you would never, ever, under any circumstances write your own cryptography package for actual deployment. But this doesn't mean that we don't want to learn how to write and understand quicksort, and the various cryptographic primitives, and speaking generally we should also want to know how to handle all of our data structures in time- and space-efficient ways. And come to that, we should also want to be able to reason about what situations those data structures would be deployed in, so we can know what library packages to use for best results in the real world.
Was This Post Helpful? 0
  • +
  • -

#21 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1948
  • View blog
  • Posts: 4,048
  • Joined: 11-December 07

Re: Reversing an Array - Use Cases

Posted 24 September 2013 - 02:02 PM

Quote

The one you find in the lab, you don't know which direction it was going, because all you get is a string of amino acids


You get a string of bases. Amino acids are proteins. DNA is a sugar phosphate backbone with bases coming off the sugar. The first image on google images illustrates it well. Here, the sugar is the pentagon and the phosphates are bonded to the 3' and 5' positions (counting the atoms clockwise form the O, starting at 1). This asymmetry gives the directionality and people talk about the "three prime" end and the "five prime" end of the chain.

Posted Image

For the complementary sequence, reversing is the first step. You then have to sqap each base for the complementary one.

Quote

True. And to sort, you call the library sort() routine, and to...


Yes, I agree with that. What I wanted to show is a way of reversing by using a wrapper class. (I want to say adapter but I think that's wrong).
Was This Post Helpful? 2
  • +
  • -

#22 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7621
  • View blog
  • Posts: 12,849
  • Joined: 19-March 11

Re: Reversing an Array - Use Cases

Posted 24 September 2013 - 02:04 PM

Looks like I've got some studying to do. Thanks!
Was This Post Helpful? 0
  • +
  • -

#23 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8327
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Reversing an Array - Use Cases

Posted 24 September 2013 - 02:08 PM

View Postjon.kiparsky, on 24 September 2013 - 05:04 PM, said:

Looks like I've got some studying to do. Thanks!

Yes a third (or would it be a fourth) PhD would be a good idea :)
Was This Post Helpful? 1
  • +
  • -

#24 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1948
  • View blog
  • Posts: 4,048
  • Joined: 11-December 07

Re: Reversing an Array - Use Cases

Posted 24 September 2013 - 02:10 PM

Quote

Looks like I've got some studying to do. Thanks!


Only if that stuff is more interesting to you than other stuff you're interested in. :)
Was This Post Helpful? 0
  • +
  • -

#25 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7621
  • View blog
  • Posts: 12,849
  • Joined: 19-March 11

Re: Reversing an Array - Use Cases

Posted 24 September 2013 - 02:39 PM

Everything is interesting. The ordering is sometimes difficult. :)
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2