Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TDDE45-2019-A-andlu984-jesjo430
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jesper Jonsson
TDDE45-2019-A-andlu984-jesjo430
Commits
31eaa758
Commit
31eaa758
authored
5 years ago
by
Andreas Lundquist
Browse files
Options
Downloads
Patches
Plain Diff
Changed project structure
parent
1fafabff
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Task_A/src/Enumerable.java
+13
-6
13 additions, 6 deletions
Task_A/src/Enumerable.java
with
13 additions
and
6 deletions
Task_A/src/Enumerable.java
+
13
−
6
View file @
31eaa758
...
...
@@ -6,14 +6,17 @@ import java.util.Iterator;
public
class
Enumerable
<
T
>
implements
Iterable
<
T
>
{
private
Iterator
<
T
>
iterator
;
private
Collection
<
T
>
collection
;
public
Enumerable
(
Collection
<
T
>
collection
)
{
this
.
iterator
=
collection
.
iterator
();
this
.
collection
=
collection
;
}
Enumerable
<
T
>
where
(
IPredicate
<
T
>
predicate
)
{
Iterator
<
T
>
oldIterator
=
iterator
;
this
.
iterator
=
new
Iterator
<
T
>()
{
Enumerable
<
T
>
enumerable
=
new
Enumerable
<>(
this
.
collection
);
Iterator
<
T
>
oldIterator
=
enumerable
.
iterator
();
enumerable
.
iterator
=
new
Iterator
<
T
>()
{
@Override
public
boolean
hasNext
()
{
...
...
@@ -26,10 +29,13 @@ public class Enumerable<T> implements Iterable<T> {
while
(
oldIterator
.
hasNext
()
&&
!
predicate
.
accept
(
item
))
{
item
=
oldIterator
.
next
();
}
return
item
;
if
(
predicate
.
accept
(
item
))
{
return
item
;
}
return
null
;
}
};
return
this
;
return
enumerable
;
}
@Override
...
...
@@ -40,8 +46,9 @@ public class Enumerable<T> implements Iterable<T> {
void
forEach
(
IAction
<
T
>
action
)
{
while
(
iterator
.
hasNext
())
{
T
t
=
(
T
)
iterator
.
next
();
action
.
perform
(
t
);
if
(
t
!=
null
)
{
action
.
perform
(
t
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment