Pedal Automobiles. The Dream of Every Soviet Child

Pedal Automobiles. The Dream of Every Soviet Child

Na ez volt az igazi királyság!!!

Advertisements
Posted in Kategorizálatlan | Leave a comment

Boolean Gray Code

Public Function GraySeq(ByVal N As Long) As String()

  ReDim ret(0 To 2 ^ N 1) As String

 

  If N = 1 Then

    ret(0) = "0": ret(1) = "1"

  ElseIf N > 1 Then

    Dim prev() As String: prev =
GraySeq(N
1)

    Dim Ix As Long

    For Ix = 0 To 2 ^ (N 1) 1

      ret(Ix) = "0" &
prev(Ix)

      ret(2 ^ (N)
1 Ix) = "1" &
prev(Ix)

    Next

  Else

    Err.Raise &H80070057, , "Invalid Parameter"

  End If

 

  GraySeq = ret

End Function

Posted in Kategorizálatlan | Leave a comment

Boolean Gray Code 4,6

?join(GraySeq(4),vbnewline)
0000
0001
0011
0010
0110
0111
0101
0100
1100
1101
1111
1110
1010
1011

1001

1000

?join(GraySeq(6),vbnewline)
000000
000001
000011
000010
000110
000111
000101
000100
001100
001101
001111
001110
001010
001011
001001
001000
011000
011001
011011
011010
011110
011111
011101
011100
010100
010101
010111
010110
010010
010011
010001
010000
110000
110001
110011
110010
110110
110111
110101
110100
111100
111101
111111
111110
111010
111011
111001
111000
101000
101001
101011
101010
101110
101111
101101
101100
100100
100101
100111
100110
100010
100011
100001
100000

Posted in Visual Basic 6 | Leave a comment

Topics

Below posts about

Features

  • Template based. Works with int-s,long-s,stl::string-s, complex object-s……
  • Parameterized Comparator function
  • Parameterized Swap function
  • Dynamic pivot value reference tracking, (no pivot value copy)
  • Only short jumps
  • Simple
  • Stack based
  • 100% unoptimized
Posted in Kategorizálatlan | Leave a comment

Compile

nasm -f elf sort.asm
g++ -Wall -c test.cpp
g++ test.o sort.o

The int version uses it’s own comparator function :

int intCompare(int* ptrA,int* ptrB) // this is our custom comparator
{
  if(ptrA && ptrB)
  {
    printf("compare %i with %i \n",*ptrA,*ptrB);
    return *ptrA-*ptrB;
  }
  else
  {
     return 1;
   }
}

 

  int init[] = {10,7,5,97,2,3,48,2};
  Array<int,8> a(init);
  a.QuickSort(&intCompare);

compare 10 with 97
compare 7 with 97
compare 5 with 97
compare 97 with 97
compare 2 with 97
compare 2 with 97
compare 3 with 97
compare 48 with 97
compare 97 with 97
compare 48 with 97
compare 10 with 2
compare 48 with 2
compare 3 with 2
compare 2 with 2
compare 7 with 2
compare 2 with 2
compare 5 with 2
compare 5 with 2
compare 2 with 2
compare 2 with 2
compare 2 with 2
compare 5 with 10
compare 7 with 10
compare 10 with 10
compare 48 with 10
compare 3 with 10
compare 5 with 7
compare 7 with 7
compare 3 with 7
compare 5 with 5
compare 3 with 5
compare 10 with 10
compare 48 with 10
compare 10 with 10

Posted in Számítógép és internet | Leave a comment

C++ int array test for quicksort

/***************************************************************************
 *   Copyright (C) 2010 by papp   *
*   vortex_32@freemail.hu
***************************************************************************/

//#ifdef HAVE_CONFIG_H
//#include <config.h>
//#endif

#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>

using namespace std;

typedef int (*ptrAbstractComparer) (void* ptrA,void* ptrB);
typedef int (*ptrAbstractUnaryCallback) (void* ptrA);
typedef int (*ptrAbstractSwap) (void* ptrA,void* ptrB);

extern "C" {void quick_sort_ex(int stride,ptrAbstractComparer ptrComparer,void* ptr_u, void* ptr_v,ptrAbstractSwap ptrSwap);}

template <class T, int N>
class Array{
    T mArray [N];

  static int Swap(T*  ptrA,T* ptrB)
  {
     T tmp = *ptrA;
     *ptrA = *ptrB;
     *ptrB = tmp;
     return 1;
  }

  static int Swap(void*  ptrA,void* ptrB)
  {
    return Swap((T*) ptrA,(T*) ptrB);
  }

  static int Compare(T* ptrA,T* ptrB)       
  {
    if(*ptrA == *ptrB) 
       return 0;
    else if(*ptrA < *ptrB)
       return -1;
    else
       return 1;
    //return *ptrA-*ptrB; this is invalid for strings, etc.
  }
  static int Compare(void* ptrA,void* ptrB)  { return Compare((T*) ptrA,(T*) ptrB ); }

  public:

    Array(){}

    Array(T (&init)[N])
    {
    for(int i= 0;i<N;i++)
    {
       mArray[i] = init[i];
    }
    }
    T& operator[](const int Index)   { return mArray[Index]; }
    const int getLength(){return N;}
    void QuickSort()              {   quick_sort_ex(sizeof(T),&Compare ,&(mArray[0]),&(mArray[N-1]),&Swap); return; }
    void QuickSort(int i,int j)   {   quick_sort_ex(sizeof(T),&Compare ,&(mArray[i]),&(mArray[j]),&Swap); return; }
    void QuickSort(int (*Comparer) (T* ptrA,T* ptrB))             
    {  
       quick_sort_ex(sizeof(T),(ptrAbstractComparer) Comparer ,&(mArray[0]),&(mArray[N-1]),&Swap); return;
    }
    void QuickSort(int i,int j,int (*Comparer) (T* ptrA,T* ptrB))
    {
       quick_sort_ex(sizeof(T),(ptrAbstractComparer) Comparer ,&(mArray[i]),&(mArray[j]),&Swap); return;
    }

};

int intCompare(int* ptrA,int* ptrB) // this is our custom comparator
{
  if(ptrA && ptrB)
  {
    printf("compare %i with %i \n",*ptrA,*ptrB);
    return *ptrA-*ptrB;
  }
  else
  {
     return 1;
   }
}

int main(int argc, char *argv[])
{
  int init[] = {10,7,5,97,2,3,48,2};

  Array<int,8> a(init);

  a.QuickSort(&intCompare);

  int x;
  for(x=0;x<a.getLength();x++)
  {
    printf("%i",a[x]);
    printf("\n");    
  }

  return EXIT_SUCCESS;
}

Posted in Kategorizálatlan | Leave a comment

C++ interface 4 asm quicksort (type == string)

Posted in Kategorizálatlan | Leave a comment