Archived

This forum has been archived. Please start a new discussion on GitHub.

Freeze Map iterator should add operator += n -=n

I think Freeze Map iterator should add operator += n , -=n

This is very wonderful function for show content in web page. for example: if db has 1000,0000 records , but I only show 10 records in one web page, then I can use pos += 900 and go through 10 records.

code like this:

FreezeMap::iterator pos;
pos = map.begin();

pos += 900;

for (int i =0;i< 10,pos != map.end(); ++pos,i++)
{
//do some thing
}

I found that Berkely DB Cursor support move function, I strong recommand ICE support this function, it's very simple , but it's very usefule

Comments

  • bernard
    bernard Jupiter, FL
    Hello,

    I don't know any Berkeley DB function that allows to skip n records while iterating over a cursor. Could you be more specific?

    Cheers,
    Bernard
  • HI bernard:
    I found it in DBcursor->c_get document , you can see it in Berkeley DB: C API ; DBcursor->c_get

    it describe like this:

    DB_SET_RECNO
    Move the cursor to the specific numbered record of the database, and return the associated key/data pair. The data field of the specified key must be a pointer to a memory location from which a db_recno_t may be read, as described in DBT. This memory location will be read to determine the record to be retrieved.

    For DB_SET_RECNO to be specified, the underlying database must be of type Btree, and it must have been created with the DB_RECNUM flag.


    thanks
  • bernard
    bernard Jupiter, FL
    Freeze currently uses only Btree databases without record numbers. Adding record numbers seems quite expensive:
    http://www.sleepycat.com/docs/api_c/db_set_flags.html#DB_RECNUM

    Cheers,
    Bernard
  • I see, Adding record numbers is quite expensive, but you can add an option to let user can select this function , if user want speed, he can forbid this function, if he want convenience, he can use this function

    thanks