Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

1035612 views
1
//
2
// util.h
3
// Bistellar
4
//
5
// Created by Alexander Thumm on 07.10.11.
6
// Copyright 2011 -. All rights reserved.
7
//
8
9
#ifndef Bistellar_util_h
10
#define Bistellar_util_h
11
12
#include <iostream>
13
#include <vector>
14
#include <deque>
15
#include <utility>
16
17
// prints a list in the format [a,b,...,z].
18
template< class Iterator >
19
void list_print(std::ostream & os, Iterator first, Iterator last)
20
{
21
os << "[";
22
if (first != last)
23
os << *first << std::flush;
24
for (first++; first != last; first++)
25
os << "," << *first << std::flush;
26
os << "]";
27
}
28
29
template< class Container, class Object >
30
void list_read(std::istream & is, Container & list)
31
{
32
is.ignore(1, '[');
33
34
if (is.eof() || is.peek() == ']')
35
{
36
is.ignore(1, ']');
37
}
38
else
39
{
40
is.unget();
41
do {
42
is.ignore(1, ',');
43
Object newObject;
44
is >> newObject;
45
list.push_back(newObject);
46
} while (!is.eof() && is.peek() != ']');
47
48
is.ignore(1, ']');
49
}
50
}
51
52
template< class T >
53
void list_read(std::istream & is, std::vector< T > & list)
54
{
55
list_read< std::vector< T >, T >(is, list);
56
}
57
58
template< class T >
59
void list_read(std::istream & is, std::deque< T > & list)
60
{
61
list_read< std::deque< T >, T >(is, list);
62
}
63
64
65
template< class T, class U >
66
std::ostream & operator<< (std::ostream & os, const std::pair<T,U> & pair )
67
{
68
os << pair.first << "," << pair.second;
69
return os;
70
}
71
72
73
// removes all duplivates from the !sorted! array base.
74
size_t remove_duplicates(void * base, size_t num, size_t size, int (* comparison)(const void *, const void *));
75
// removes all elements of the !sorted! array base2 from the !sorted! array base.
76
size_t remove_from_set(void * base, size_t num, const void * base2, size_t num2, size_t size, int (* comparison)(const void *, const void *));
77
78
#endif
79
80