p-nand-q.com | home | computer | humor | business | pictures | about

humor

# Quicksort best practices in Java

Being a modern business oriented language, Java lends itself ideally to cost-minimized implementations of abstract algorithms as the shit I don't know enough buzzwords sort algorithm everybody mistakenly names bubblesort. Sort of.

The following code shows how to do this is objectoriented Java. Pure Java, 100%. With lots of News, and only a handful of semicolons. You can compare it with my python and C# and plain c solutions - you'll probably agree that Java compares favourably in terms of unlackingness. Speedwise however C is still unbeatable when it comes to tightly optimized non-recursive quicksorting

```import java.lang.*;

class quicksort
{
public quicksort(Object [] Q)
{
U = new Object[Q.length*2+100];

new A(Q,
new B(0,
new C(0,
new D(0,
new E(3,
new F(0,
new B(0,
new C(4,
new D(0,
new G(1,
new E(4,
new B(0,
new E(4,
new D(0,
new G(5,
new C(Q.length,
new B(0,
new C(4,
new D(0,
new G(1,
new E(4,
new B(0,
new E(4,
new D(0,
new C(6,
new H(0,
new C(2,
new D(0,
new C(4,
new B(0,
new C(4,
new D(0,
new G(6,
new E(0,
new I(Q,
new B(0,
new E(1,
new D(0,
new E(1,
new J(0,
new B(0,
new C(0,
new D(0,
new C(0,null))))))))))))))))))))))))))))))))))))))))))));}class J extends o{public J(int N,o O){
new L(
new K(0,null),
new C(0,(M<U.length)?
new J(0,
new C(0,
new B(0,
new C(0,
new D(0,
new G(1,
new E(0,
new B(0,
new E(0,
new D(0,
new C(0,null))))))))))):null));}}class L extends o{public L(o a, o b){}}class A extends o{public A(Object[]Q,o O){
new L(
new E(0,
new D(0,
new C(Q.length,null))),
new C(0,(M<R)?
new A(Q,
new B(0,
new C(0,
new D(0,
new G(1,
new E(0,
new P(Q,
new E(0,
new D(0,
new K(0,
new G(6,
new E(0,null)))))))))))):null));}}class S extends o{public S(int N,o O){U[N]=O;}}class T extends o{public T(int N, o O){M=compare(M,R);}}class V extends o{public V(int N,o O){
new E(1,
new D(0,
new K(0,
new G(4,
new E(4,null)))));
new C(0,((M==R)&&(U[5]==null))?
new V(0,
new L(
new K(0,
new G(2,
new E(4,
new D(0,
new K(0,
new G(3,
new E(4,
new B(0,
new G(2,
new E(4,
new D(0,
new W(1,
new K(0,
new G(2,
new E(4,null))))))))))))))),
new C(M,(M==R)?
new B(0,
new G(4,
new E(4,
new D(0,
new E(4,null))))):
new L(
new T(0,
new K(0,
new K(0,
new G(2,
new E(4,
new D(0,
new E(1,null))))))),
new C(0,(M<0)?
new B(0,
new C(5,
new B(0,
new K(0,
new G(3,
new E(4,
new D(0,
new K(0,
new K(0,
new G(2,
new E(4,null))))))))))):null))))):null);}}class C extends o{public C(int N,o O){M = N;}}class B extends o{public B(int N,o O){U[M]=R;}}class H extends o{public H(int N,o O){U[M]=U[R];}}class P extends o{public P(Object[] Q,o O){Q[M]=R;}}class o extends Object{}class E extends o{public E(int N,o O){M=(Integer)U[N];}}class Y extends o{public Y(int N,o O){
new L(
new K(0,
new G(4,
new E(4,
new D(0,
new E(1,null))))),
new C(0,((M==R)&&(U[5]==null))?
new Y(0,
new L(
new K(0,
new G(3,
new E(4,
new D(0,
new K(0,
new G(2,
new E(4,
new B(0,
new G(3,
new E(4,
new D(0,
new G(1,
new K(0,
new G(3,
new E(4,null))))))))))))))),
new C(0,(M==R)?
new B(0,
new G(4,
new E(4,
new D(0,
new E(4, null))))):
new L(
new T(0,
new K(0,
new K(0,
new G(3,
new E(4,
new D(0,
new E(1, null))))))),
new C(0,(M>0)?
new H(0,
new C(5,
new D(0,
new C(1,
new B(0,
new K(0,
new G(2,
new E(4,
new D(0,
new K(0,
new K(0,
new G(3,
new E(4,null))))))))))))):null))))):null));}}class I extends o{public I(Object[] Q,o O){
new L(
new E(0,
new D(0,
new C(Q.length,null))),
new C(0,(M<R)?
new I(Q,
new B(0,
new C(0,
new D(0,
new G(1,
new E(0,
new B(0,
new G(6,
new E(0,
new X(Q,
new E(0,null))))))))))):null));}}class K extends o{public K(int N,o O){M=(Integer)U[M];}}class G extends o{public G(int N,o O){M+=N;}}class W extends o{public W(int N,o O){M-=N;}}class F extends o{public F(int N,o O){
new L(
new E(4,
new D(0,
new E(2,null))),
new C(0,(M!=R)?
new F(0,
new L(
new K(0,
new E(4,
new D(0,
new K(0,
new G(1,
new E(4,
new B(0,
new C(4,
new D(0,
new W(2,
new E(4,null))))))))))),
new C(0,(M<R)?
new B(0,
new C(4,
new D(0,
new G(4,
new E(4,
new B(0,
new G(2,
new E(4,
new D(0,
new G(1,
new K(0,
new G(2,
new E(4,
new B(0,
new G(1,
new E(4,
new D(0,
new W(1,
new K(0,
new G(2,
new E(4,
new B(0,
new G(3,
new E(4,
new D(0,
new K(0,
new G(1,
new E(4,
new B(0,
new K(0,
new G(2,
new E(4,
new D(0,
new E(1,
new Z(0,
new H(0,
new G(4,
new E(4,
new D(0,
new C(1,
new B(0,
new G(2,
new E(4,
new D(0,
new K(0,
new G(1,
new E(4,
new B(0,
new G(3,
new E(4,
new D(0,
new W(1,
new K(0,
new E(4,
new B(0,
new C(1,
new D(0,
new K(0,
new K(0,
new G(1,
new E(4,null))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))):null))):null));}}protected Object[]U;class D extends o{public D(int N,o O){N=M;M=R;R=N;}}int M;class X extends o{public X(Object[]Q,o O){R=(Integer)Q[M];}}int R;class Z extends o{public Z(int N,o O){
new L(
new K(0,
new G(4,
new E(4,
new D(0,
new E(1, null))))),
new C(0,(M==R)?
new Z(0,
new L(
new Y(0,
new S(5, null)),
new V(0,
new S(5, null)))):null));}
}

protected int compare(Object a,Object b)
{
return ((Integer)a).compareTo((Integer)b);
}
}

public class qs
{
public static void main(String[] args)
{
Integer [] test = new Integer[100];
for( int i = 0; i < test.length; i++ )
test[i] = (int) (Math.random() * 10000);

new quicksort(test);
for( int i = 0; i < test.length; i++ )
System.out.print(test[i] + "," );
System.out.println();

}
}
```