Search:

Type: Posts; User: RichSelian

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Reading blocks of binary data into a vector?

    Instead of


    while(vec.size() < 65536 && (ch = stream.get(), !stream.eof()))
    vec.push_back(ch);

    Is there any elegant way of doing that?
  2. clang++ works but g++ doesn't -- Maybe a compiler bug?

    clang++ can compile the following code without any error and warning, but g++ always gives me the error "no matching call ..."? Is it a bug of g++ or kind of extensions of clang++?


    #include...
  3. Replies
    3
    Views
    1,850

    Under linux, you can use getenv() in stdlib.h to...

    Under linux, you can use getenv() in stdlib.h to retrieve the environment variable "HOME". But I don't know whether it works under windows.
  4. Replies
    1
    Views
    1,632

    Use inline functions instead of macros?

    The code is here. C Mozilla Pastebin - collaborative debugging tool

    I'm writing heap sort as an inline function and a macro with the same implementation. In my test, the inline function runs much...
  5. Replies
    17
    Views
    17,713

    #define cmp(x, y) ((x)-(y)); This implementation...

    #define cmp(x, y) ((x)-(y)); This implementation may course overflow and return the wrong result.

    Any better idea? or am I going to write ugly int_cmp() short_cmp() char_cmp()/... using the inline...
  6. Replies
    10
    Views
    1,794

    You can simply modify the swap function in the...

    You can simply modify the swap function in the sorting procedure.
    But why not use something like a structure?
  7. Replies
    17
    Views
    17,713

    Writing a macro to compare two numbers?

    I want such a macro in my project: cmp(x, y) returns a positive number when x > y, a negative number when x < y, and 0 when x == y. of course I know the simplest way:


    #define cmp(x, y) (((x) >...
  8. Replies
    6
    Views
    2,023

    working under linux...

    working under linux...
  9. Replies
    6
    Views
    2,023

    threaded-safe exception handling?

    I'm thinking of implementing exception handling in C and extractly I have written a simple one. But it's not threaded-safe. Can you have me fix it, or is there any similar implementation for...
  10. Yes, but you use recursion, that will slow down...

    Yes, but you use recursion, that will slow down the speed.

    My tree will become unbalanced after times of deletion and one search operation will cost O(n), but searching a deep node will restore...
  11. But it's quite faster than a normal avl tree. My...

    But it's quite faster than a normal avl tree. My balancing operation is top-down and it doesn't require any recursion or parent pointers, so it can save a lot of time and memory space.
    The condition...
  12. This is a simple test code: //...

    This is a simple test code:


    // #############################################################################
    // # FileName: topdown.c
    // # Author: Zhang Li, CS0901, HUST
    //...
  13. Maybe I invented a new type of Balanced Binary Search Tree?

    I wrote this code just for fun, but then I found that it's performance is excellent in both speed (faster then std::map) and memory space, and it's very easy to implement. But I lack some mathemetic...
  14. Replies
    4
    Views
    2,349

    I use my own stack instead of the system's and...

    I use my own stack instead of the system's and now it works, thank you!
  15. Replies
    4
    Views
    2,349

    How to destroy a splay tree?

    I create a top-down splay tree but don't know how to destroy it? Since the tree can be very deep, the recursive destruction sometimes cause stack overflow. How can I get it work without changing the...
  16. Replies
    7
    Views
    5,710

    Of course I know that. But I'm trying generic...

    Of course I know that. But I'm trying generic programming in C so I need macros to do that.
    For example, now I have an implementation of avltree and want to use it as a dictionary. I have to write a...
  17. Replies
    7
    Views
    5,710

    That may be a little crazy, but I want to...

    That may be a little crazy, but I want to implement syntax-candy like this:


    MAPITEM_TYPE(int, const char*) mapitem;

    MAPITEM_KEY(mapitem) = 1;
    MAPITEM_VAL(mapitem) = "Hello";...
  18. Replies
    7
    Views
    5,710

    sucks

    int main()
    {
    struct
    {
    int m_aa;
    int m_bb;
    } a = {0, 1};

    struct
    {
  19. Replies
    5
    Views
    2,747

    You know every types of pointers are the same --...

    You know every types of pointers are the same -- they are all unsigned integers. So you can convert them to whatever types you want. And using void* seems better here.
  20. Replies
    4
    Views
    2,555

    I have a recursive verion which costs just 0.7sec...

    I have a recursive verion which costs just 0.7sec sorting 100,000 integers. This non-recursive version just replace the system's stack with its own, then it costs almost 1.5sec.
    The non-recursive...
  21. Replies
    2
    Views
    25,848

    that comparing function is foolish. it returns 1...

    that comparing function is foolish. it returns 1 when the last elements is equal.


    // the correct one:
    int equal_arrays(int a1 [], int a2 [], int n)
    {
    int i, result;
    for (i=0; i<n; ++i)...
  22. Replies
    14
    Views
    7,044

    grades[i+1] overflowed when i == 99

    grades[i+1] overflowed when i == 99
  23. Replies
    4
    Views
    2,555

    non-recursive quicksort is too slow?

    I implemented a macro of the non-recursive quicksort, but I found it much slower than I expected (it's slower than non-recursive mergesort). Is the non-recursive quicksort always slow? or I made some...
  24. Replies
    7
    Views
    3,528

    COMPRESS.C says "This implementation uses...

    COMPRESS.C says "This implementation uses multiple binary trees to speed up the search for the
    longest match", but it didn't describe how to construct those trees and how they work.
  25. Replies
    7
    Views
    3,528

    The algorithm needs to match a string in...

    The algorithm needs to match a string in (4096*16=65536) strings, but it seems it uses only 4096 nodes for the tree. I just cannot understand how he can do that.
Results 1 to 25 of 75
Page 1 of 3 1 2 3