Skip to content

nyuichi/xrope

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xrope Build Status

rope data structre

Usage

Just include "xrope.h" anywhere you want to use xrope!

API

typedef struct xrope xrope;

/**
 * | name         | frees buffer? | end with NULL? | complexity | misc
 * | ----         | ----          | ----           | ----       | ---
 * | xr_new_cstr  | no            | yes            | O(1)       | xr_new(_lit)
 * | xr_new_imbed | no            | no             | O(1)       |
 * | xr_new_move  | yes           | yes            | O(1)       |
 * | xr_new_copy  | yes           | no             | O(n)       |
 */

#define xr_new(cstr) xr_new_cstr(cstr, strlen(cstr))
#define xr_new_lit(cstr) xr_new_cstr(cstr, sizeof(cstr) - 1)
static inline xrope *xr_new_cstr(const char *, size_t);
static inline xrope *xr_new_imbed(const char *, size_t);
static inline xrope *xr_new_move(const char *, size_t);
static inline xrope *xr_new_copy(const char *, size_t);


static inline void XROPE_INCREF(xrope *);
static inline void XROPE_DECREF(xrope *);

static inline size_t xr_len(xrope *);
static inline char xr_at(xrope *, size_t);
static inline xrope *xr_cat(xrope *, xrope *);
static inline xrope *xr_sub(xrope *, size_t, size_t);
static inline const char *xr_cstr(xrope *); /* returns NULL-terminated string */

TODO

  • self-balancing
  • unicode support?
  • custom allocator
  • more test cases

Author

Yuichi Nishiwaki (yuichi@idylls.jp)

About

rope data structure

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages