~ubuntu-branches/ubuntu/hardy/avidemux/hardy

« back to all changes in this revision

Viewing changes to avidemux/ADM_toolkit/ADM_queue.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2006-12-15 17:13:20 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20061215171320-w79pvpehxx2fr217
Tags: 1:2.3.0-0.0ubuntu1
* Merge from debian-multimedia.org, remaining Ubuntu change:
  - desktop file,
  - no support for ccache and make -j.
* Closes Ubuntu: #69614.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
              
 
3
    copyright            : (C) 2006 by mean
 
4
    email                : fixounet@free.fr
 
5
 ***************************************************************************/
 
6
 
 
7
/***************************************************************************
 
8
 *                                                                         *
 
9
 *   This program is free software; you can redistribute it and/or modify  *
 
10
 *   it under the terms of the GNU General Public License as published by  *
 
11
 *   the Free Software Foundation; either version 2 of the License, or     *
 
12
 *   (at your option) any later version.                                   *
 
13
 *                                                                         *
 
14
 ***************************************************************************/
 
15
#include "config.h"
 
16
 
 
17
#include <stdio.h>
 
18
#include <stdlib.h>
 
19
#include <string.h>
 
20
#include <ADM_assert.h>
 
21
#include "ADM_library/default.h"
 
22
#include "ADM_toolkit/ADM_threads.h"
 
23
#include "ADM_queue.h"
 
24
 
 
25
ADM_queue::ADM_queue()
 
26
{
 
27
  head=NULL;
 
28
  tail=NULL;
 
29
}
 
30
ADM_queue::~ADM_queue()
 
31
{
 
32
  if(head)
 
33
  {
 
34
    printf(">>>>>>>>Warning queue is not empty\n<<<<<<<"); 
 
35
  }
 
36
}
 
37
uint8_t ADM_queue::isEmpty(void)
 
38
{
 
39
  if(head) return 0;
 
40
  ADM_assert(!tail);
 
41
  return 1; 
 
42
}
 
43
uint8_t ADM_queue::push(void *data)
 
44
{
 
45
  queueElem *elem=new queueElem;
 
46
  
 
47
  elem->next=NULL;
 
48
  elem->data=data;
 
49
  if(!head)
 
50
  {
 
51
    head=tail=elem; 
 
52
    return 1;
 
53
  }
 
54
  ADM_assert(tail);
 
55
  tail->next=elem;
 
56
  tail=elem;
 
57
  return 1;
 
58
}
 
59
uint8_t ADM_queue::pushBack(void *data)
 
60
{
 
61
  queueElem *elem=new queueElem;
 
62
 
 
63
  elem->next=head;
 
64
  elem->data=data;
 
65
  if(!head) tail=elem;
 
66
  head=elem;
 
67
  return 1;
 
68
}
 
69
uint8_t ADM_queue::pop(void **data)
 
70
{
 
71
  ADM_assert(head);
 
72
  *data=NULL;
 
73
  if(isEmpty()) return 0;
 
74
  *data=head->data;
 
75
  queueElem *tmp=head;
 
76
  head=head->next;
 
77
  if(!head)
 
78
  {
 
79
    head=tail=NULL; 
 
80
  }
 
81
  delete tmp;
 
82
  return 1;
 
83
}
 
84
//EOF