Skip to content

Commit

Permalink
fix bubble sort function wording
Browse files Browse the repository at this point in the history
  • Loading branch information
jimthunderbird committed Mar 2, 2015
1 parent 1256673 commit c680a4a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -561,17 +561,17 @@ class Sorter
{
public function bubbleSort($arr)
{
$result = call_c_function("sorting.c","test_bubble_sort",$arr);
$result = call_c_function("sorting.c","bubble_sort",$arr);

return $result;
}
}
```
####It is pretty straightforward at this point, we have a Sorter class and inside we have the bubbleSort method, it takes an array $arr and it will return the sorted array. Inside the method, we have this code:
```php
$result = call_c_function("sorting.c","test_bubble_sort",$arr);
$result = call_c_function("sorting.c","bubble_sort",$arr);
```
####This means we will be calling the test_bubble_sort function inside of sorting.c file, and the test_bubble_sort function takes $arr as the input parameter. And the result of the test_bubble_sort function call will be stored in the $result variable.
####This means we will be calling the bubble_sort function inside of sorting.c file, and the bubble_sort function takes $arr as the input parameter. And the result of the bubble_sort function call will be stored in the $result variable.
####Now let's create src/sorting.c file:
```php
static zval * bubble_sort(zval * arr)
Expand Down Expand Up @@ -612,7 +612,7 @@ static zval * bubble_sort(zval * arr)
return result;
}
```
####To understand what's going on in the test_bubble_sort C function, it requires some knowledge of the internal Zend Engine's data structure.
####To understand what's going on in the bubble_sort C function, it requires some knowledge of the internal Zend Engine's data structure.
####In the function we will accept a poiner to a zval, which is pointing to the array we pass from PHP. Then we create a pointer to the array's hashtable.
####We then create an array of long integers, holding each long integer value in the arBuckets of the array's hashtable.
####Later on we perform the standard bubble sort on the long integer array, and finally use the zend array_init add_index_long apis to create a new sorted array and return the result back.
Expand Down

0 comments on commit c680a4a

Please sign in to comment.