From 2c88b00fb8012d6dbbfe85d56a78f8ed776b7b72 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Thu, 17 Sep 2015 19:44:12 -0400 Subject: [PATCH] fixed a line wrapping --- index.html | 56 ++++-------------------------------------------------- 1 file changed, 4 insertions(+), 52 deletions(-) diff --git a/index.html b/index.html index 521ac6a..c464a68 100644 --- a/index.html +++ b/index.html @@ -193,8 +193,6 @@ Error message and password prompt
  • CSS
  • -
  • Draft of 'KBtree: generic ordered map'
  • -
  • Generic Programming in C
  • KBtree: generic ordered map
  • @@ -5769,7 +5767,7 @@ pre .xml .cdata {
    lh3
    -
    +
    
     
    @@ -5916,53 +5914,6 @@ code { color: #333333; }
    -
    -
    !!Synopsis
    -* Functionality: generic balanced search tree based on B-tree.
    -* Library source code: [[kbtree.h|https://github.com/attractivechaos/klib/blob/master/kbtree.h]]
    -* Dependencies: none
    -* Related articles: [[B-tree vs binary search tree|https://attractivechaos.wordpress.com/2008/09/24/b-tree-vs-binary-search-tree/]] and [[Another look at my old benchmark|https://attractivechaos.wordpress.com/2008/10/07/another-look-at-my-old-benchmark/]]
    -!!Example
    -!!!Example 1: count distinct words on the command line
    -```c
    -// gcc -O2 this_prog.c; ./a.out two one three two three three
    -#include <stdio.h>
    -#include "kbtree.h"
    -
    -typedef struct {
    -    char *key;
    -    int count;
    -} elem_t;
    -
    -#define elem_cmp(a, b) (strcmp((a).key, (b).key))
    -KBTREE_INIT(str, elem_t, elem_cmp)
    -
    -int main(int argc, char *argv[])
    -{
    -    kbtree_t(str) *b;
    -    elem_t *p, t;
    -    kbitr_t itr;
    -    int i;
    -    b = kb_init(str, KB_DEFAULT_SIZE);
    -    for (i = 1; i < argc; ++i) {
    -        // no need to allocate; just use pointer
    -        t.key = argv[i], t.count = 1;
    -        p = kb_getp(str, b, &t); // kb_get() also works
    -        // IMPORTANT: put() only works if key is absent
    -        if (!p) kb_putp(str, b, &t);
    -        else ++p->count;
    -    }
    -    // ordered tree traversal
    -    kb_itr_first(str, b, &itr); // get an iterator pointing to the first
    -    for (; kb_itr_valid(&itr); kb_itr_next(str, b, &itr)) { // move on
    -        p = &kb_itr_key(elem_t, &itr);
    -        printf("%d\t%s\n", p->count, p->key);
    -    }
    -    kb_destroy(str, b);
    -    return 0;
    -}
    -```
    -
    For the implementation of generic [[containers|http://en.wikipedia.org/wiki/Container_(abstract_data_type)]], klib extensively uses C
     macros. To use these data structures, we usually need to instantiate methods by
    @@ -6101,7 +6052,7 @@ as type-specific code. A generic library written with `void*` will not get such
     performance boost.
     
    -
    +
    !!Synopsis
     * Functionality: generic balanced search tree based on B-tree.
     * Library source code: [[kbtree.h|https://github.com/attractivechaos/klib/blob/master/kbtree.h]]
    @@ -6138,7 +6089,8 @@ int main(int argc, char *argv[])
             else ++p->count;
         }
         // ordered tree traversal
    -    for (kb_itr_first(str, b, &itr); kb_itr_valid(&itr); kb_itr_next(str, b, &itr)) {
    +    kb_itr_first(str, b, &itr); // get an iterator pointing to the first
    +    for (; kb_itr_valid(&itr); kb_itr_next(str, b, &itr)) { // move on
             p = &kb_itr_key(elem_t, &itr);
             printf("%d\t%s\n", p->count, p->key);
         }
    -- 
    2.47.3