-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcollection_interface.f90
68 lines (51 loc) · 1.75 KB
/
collection_interface.f90
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
65
66
67
68
!=====================================================================!
! Interface for all collection classes
!
! Author: Komahan Boopathy ([email protected])
!=====================================================================!
module collection_interface
use iterator_interface, only : iterator
use object_class, only : object
implicit none
private
public :: collection
type, extends(object), abstract :: collection
contains
! provided methods
!!$ procedure :: add
!!$ procedure :: add_all
!!$ procedure :: clear
procedure(contains), deferred :: contains
!!$ procedure :: contains_all
procedure(is_empty), deferred :: is_empty
!!$ procedure :: remove
!!$ procedure :: remove_all
!!$ procedure :: retain_all
!!$ procedure :: to_array
!!$ procedure :: to_string
procedure(get_iterator), deferred :: get_iterator
procedure(size), deferred :: size
end type collection
interface
pure type(logical) function is_empty(this)
import collection
class(collection), intent(in) :: this
end function is_empty
type(logical) function contains(this, element)
import collection, object, iterator
class(collection) , intent(in) :: this
class(object) , intent(in) :: element
class(iterator) , allocatable :: it
end function contains
pure type(integer) function size(this)
import collection
class(collection), intent(in) :: this
end function size
pure function get_iterator(this)
import collection, iterator
class(collection), intent(in) :: this
class(iterator) , allocatable :: get_iterator
end function get_iterator
end interface
contains
end module collection_interface