- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
_list_pq.c
资源名称:leda.tar.gz [点击查看]
上传用户:gzelex
上传日期:2007-01-07
资源大小:707k
文件大小:1k
源码类别:
数值算法/人工智能
开发平台:
MultiPlatform
- /*******************************************************************************
- +
- + LEDA-R 3.2.3
- +
- + _list_pq.c
- +
- + Copyright (c) 1995 by Max-Planck-Institut fuer Informatik
- + Im Stadtwald, 66123 Saarbruecken, Germany
- + All rights reserved.
- +
- *******************************************************************************/
- #include <LEDA/impl/list_pq.h>
- list_pq::list_pq(const list_pq&) { /* copy constructor */}
- list_pq& list_pq::operator=(const list_pq&) { /* assignment */ return *this; }
- list_pq_item list_pq::insert(GenPtr k,GenPtr i)
- { copy_key(k);
- copy_inf(i);
- list_pq_item p = new list_pq_elem(k,i,nil,head);
- if (head) head->pred = p;
- head = p;
- count++;
- return p;
- }
- list_pq_item list_pq::find_min() const
- { list_pq_item p = head;
- list_pq_item m = head;
- if (int_type())
- while (p)
- { if (LEDA_ACCESS(int,p->key) < LEDA_ACCESS(int,m->key)) m = p;
- p = p->succ;
- }
- else
- while (p)
- { if (cmp(p->key,m->key) < 0) m = p;
- p = p->succ;
- }
- return m;
- }
- void list_pq::del_item(list_pq_item it)
- { list_pq_item p = it->pred;
- list_pq_item s = it->succ;
- if (p) p->succ = s;
- else head = s;
- if (s) s->pred = p;
- count--;
- }
- void list_pq::clear()
- { while (head)
- { list_pq_item p = head->succ;
- clear_key(head->key);
- clear_inf(head->inf);
- delete head;
- head = p;
- }
- count = 0;
- }