summaryrefslogtreecommitdiff
path: root/examples/Misc/test_set.cpp
blob: b5c81d64bc8802cd7f1c27d02a71a4f50d354e3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// $Id$

#include "ace/OS_main.h"
#include "ace/Containers.h"
#include "ace/Log_Msg.h"

int
ACE_TMAIN (int, ACE_TCHAR *[])
{
  ACE_Unbounded_Set<int> s1;

  ACE_ASSERT (s1.size () == 0);
  s1.insert_tail (10);
  s1.insert_tail (20);
  ACE_ASSERT (s1.size () == 2);

  ACE_Unbounded_Set<int> s2 (s1);
  ACE_ASSERT (s2.size () == 2);

  ACE_Unbounded_Set<int> s3;
  ACE_ASSERT (s3.size () == 0);

  s3 = s2;
  ACE_ASSERT (s3.size () == s2.size ());

  ACE_Unbounded_Set<int> s4 (s3);
  ACE_ASSERT (s4.size () == 2);

  int *ip = 0;

  ACE_DEBUG ((LM_DEBUG, "dumping s1\n"));
  for (ACE_Unbounded_Set_Iterator<int> iter1 (s1);
       iter1.next (ip) != 0;
       iter1.advance ())
    ACE_DEBUG ((LM_DEBUG, "item = %d\n", *ip));

  ACE_DEBUG ((LM_DEBUG, "dumping s2\n"));
  for (ACE_Unbounded_Set_Iterator<int> iter2 (s2);
       iter2.next (ip) != 0;
       iter2.advance ())
    ACE_DEBUG ((LM_DEBUG, "item = %d\n", *ip));

  ACE_DEBUG ((LM_DEBUG, "dumping s3\n"));
  for (ACE_Unbounded_Set_Iterator<int> iter3 (s3);
       iter3.next (ip) != 0;
       iter3.advance ())
    ACE_DEBUG ((LM_DEBUG, "item = %d\n", *ip));

  ACE_DEBUG ((LM_DEBUG, "dumping s4\n"));
  for (ACE_Unbounded_Set_Iterator<int> iter4 (s4);
       iter4.next (ip) != 0;
       iter4.advance ())
    ACE_DEBUG ((LM_DEBUG, "item = %d\n", *ip));

  return 0;
}

#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Unbounded_Set<int>;
template class ACE_Unbounded_Set_Iterator<int>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate ACE_Unbounded_Set<int>
#pragma instantiate ACE_Unbounded_Set_Iterator<int>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */