/* Pepito v1.59  -- file: skipl.h --
   Copyright (c) 2000-01 Carlos del Cacho

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.

   Contact the author: guggenjaimito@yahoo.com
*/

#ifndef SKIPL_H
#define SKIPL_H

// maximo numero de niveles permitidos por la lista

#define MAX_LEVELS    32

//---------------------------
typedef struct sl_entry_struct {

    void *key;
    void *data;
    int data_size;
    struct sl_entry_struct **next;

} sl_entry;


//---------------------------
typedef struct {

    int max_level;
    int key_size;
    int nentries;
    sl_entry *levels;

} skip_list;


int SL_Insert(skip_list *sl, void *key, void *data, int data_size, void       (*pfun)(void *, int, void *, int));
int SL_Delete(skip_list *sl, void *key);
int SL_Find(skip_list *sl, void *key, void **data);
sl_entry *SL_ExtractFirst(skip_list *sl);
void SL_FreeEntry(sl_entry *pe);
int SL_Init(skip_list *sl, int key_size);
int SL_CheckConsistency(skip_list *sl);
int SL_Print(skip_list *sl);
void SL_DestroyList(skip_list *sl);
#endif
