Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
20250331
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
20250331
Commits
e3b8881d
Commit
e3b8881d
authored
Apr 01, 2025
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pierwsze lambdy
parent
13bb6d93
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
67 additions
and
4 deletions
+67
-4
ForkJoin1_SumArray.java
src/main/java/gotowe/p50_watki/pule/ForkJoin1_SumArray.java
+1
-1
ForkJoin2_SumArray_Limit_Get.java
...a/gotowe/p50_watki/pule/ForkJoin2_SumArray_Limit_Get.java
+1
-1
ForkJoin3_SumArray_Limit_Join.java
.../gotowe/p50_watki/pule/ForkJoin3_SumArray_Limit_Join.java
+1
-1
ForkJoin4_SumArray_RecursiveTask.java
...towe/p50_watki/pule/ForkJoin4_SumArray_RecursiveTask.java
+1
-1
PuleWatkow_Lambda.java
src/main/java/gotowe/p50_watki/pule/PuleWatkow_Lambda.java
+5
-0
FunkcjaLiczbowa.java
src/main/java/na_zywo/lambdy/FunkcjaLiczbowa.java
+9
-0
Operacje.java
src/main/java/na_zywo/lambdy/Operacje.java
+11
-0
Przyklady.java
src/main/java/na_zywo/lambdy/Przyklady.java
+38
-0
No files found.
src/main/java/gotowe/p50_watki/pule/ForkJoin1_SumArray.java
View file @
e3b8881d
...
@@ -57,7 +57,7 @@ public class ForkJoin1_SumArray {
...
@@ -57,7 +57,7 @@ public class ForkJoin1_SumArray {
final
ThreadLocalRandom
random
=
ThreadLocalRandom
.
current
();
final
ThreadLocalRandom
random
=
ThreadLocalRandom
.
current
();
System
.
out
.
println
(
"Losowanie..."
);
System
.
out
.
println
(
"Losowanie..."
);
for
(
int
i
=
0
;
i
<
tab
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
tab
.
length
;
i
++)
tab
[
i
]
=
(
byte
)
random
.
nextInt
(
256
);
tab
[
i
]
=
(
byte
)
random
.
nextInt
(
128
);
Long
result
;
Long
result
;
System
.
out
.
println
(
"\nLiczenie sekwencyjne:"
);
System
.
out
.
println
(
"\nLiczenie sekwencyjne:"
);
...
...
src/main/java/gotowe/p50_watki/pule/ForkJoin2_SumArray_Limit_Get.java
View file @
e3b8881d
...
@@ -59,7 +59,7 @@ public class ForkJoin2_SumArray_Limit_Get {
...
@@ -59,7 +59,7 @@ public class ForkJoin2_SumArray_Limit_Get {
final
ThreadLocalRandom
random
=
ThreadLocalRandom
.
current
();
final
ThreadLocalRandom
random
=
ThreadLocalRandom
.
current
();
System
.
out
.
println
(
"Losowanie..."
);
System
.
out
.
println
(
"Losowanie..."
);
for
(
int
i
=
0
;
i
<
tab
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
tab
.
length
;
i
++)
tab
[
i
]
=
(
byte
)
random
.
nextInt
(
256
);
tab
[
i
]
=
(
byte
)
random
.
nextInt
(
128
);
Long
result
;
Long
result
;
final
ForkJoinPool
pool
=
new
ForkJoinPool
(
8
);
final
ForkJoinPool
pool
=
new
ForkJoinPool
(
8
);
...
...
src/main/java/gotowe/p50_watki/pule/ForkJoin3_SumArray_Limit_Join.java
View file @
e3b8881d
...
@@ -55,7 +55,7 @@ public class ForkJoin3_SumArray_Limit_Join {
...
@@ -55,7 +55,7 @@ public class ForkJoin3_SumArray_Limit_Join {
final
ThreadLocalRandom
random
=
ThreadLocalRandom
.
current
();
final
ThreadLocalRandom
random
=
ThreadLocalRandom
.
current
();
System
.
out
.
println
(
"Losowanie..."
);
System
.
out
.
println
(
"Losowanie..."
);
for
(
int
i
=
0
;
i
<
tab
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
tab
.
length
;
i
++)
tab
[
i
]
=
(
byte
)
random
.
nextInt
(
256
);
tab
[
i
]
=
(
byte
)
random
.
nextInt
(
128
);
Long
result
;
Long
result
;
final
ForkJoinPool
pool
=
new
ForkJoinPool
(
8
);
final
ForkJoinPool
pool
=
new
ForkJoinPool
(
8
);
...
...
src/main/java/gotowe/p50_watki/pule/ForkJoin4_SumArray_RecursiveTask.java
View file @
e3b8881d
...
@@ -42,7 +42,7 @@ public class ForkJoin4_SumArray_RecursiveTask {
...
@@ -42,7 +42,7 @@ public class ForkJoin4_SumArray_RecursiveTask {
final
ThreadLocalRandom
random
=
ThreadLocalRandom
.
current
();
final
ThreadLocalRandom
random
=
ThreadLocalRandom
.
current
();
System
.
out
.
println
(
"Losowanie..."
);
System
.
out
.
println
(
"Losowanie..."
);
for
(
int
i
=
0
;
i
<
tab
.
length
;
i
++)
for
(
int
i
=
0
;
i
<
tab
.
length
;
i
++)
tab
[
i
]
=
(
byte
)
random
.
nextInt
(
256
);
tab
[
i
]
=
(
byte
)
random
.
nextInt
(
128
);
Long
result
;
Long
result
;
final
ForkJoinPool
pool
=
new
ForkJoinPool
(
8
);
final
ForkJoinPool
pool
=
new
ForkJoinPool
(
8
);
...
...
src/main/java/gotowe/p50_watki/pule/PuleWatkow_Lambda.java
View file @
e3b8881d
...
@@ -18,6 +18,11 @@ public class PuleWatkow_Lambda {
...
@@ -18,6 +18,11 @@ public class PuleWatkow_Lambda {
}
}
String
s
=
futureString
.
get
();
String
s
=
futureString
.
get
();
System
.
out
.
println
(
"gotowe: "
+
s
);
System
.
out
.
println
(
"gotowe: "
+
s
);
pool
.
shutdown
();
// bez shutdown poniższy kod czekalby minutę, bo "może będą jeszcze jakieś zlecenia"
if
(
pool
.
awaitTermination
(
1
,
TimeUnit
.
MINUTES
))
{
System
.
out
.
println
(
"wszystko zrobione"
);
}
}
}
}
}
}
}
src/main/java/na_zywo/lambdy/FunkcjaLiczbowa.java
0 → 100644
View file @
e3b8881d
package
na_zywo
.
lambdy
;
public
interface
FunkcjaLiczbowa
{
double
oblicz
(
double
arg
);
default
String
hello
()
{
return
"Hello!"
;
}
}
src/main/java/na_zywo/lambdy/Operacje.java
0 → 100644
View file @
e3b8881d
package
na_zywo
.
lambdy
;
public
class
Operacje
{
public
static
void
zmienTablice
(
double
[]
t
,
FunkcjaLiczbowa
f
)
{
for
(
int
i
=
0
;
i
<
t
.
length
;
i
++)
{
t
[
i
]
=
f
.
oblicz
(
t
[
i
]);
}
}
}
src/main/java/na_zywo/lambdy/Przyklady.java
0 → 100644
View file @
e3b8881d
package
na_zywo
.
lambdy
;
import
java.util.Arrays
;
public
class
Przyklady
{
public
static
void
main
(
String
[]
args
)
{
// "klasa anonimowa" dostępna od Java 1.1
FunkcjaLiczbowa
a
=
new
FunkcjaLiczbowa
()
{
public
double
oblicz
(
double
arg
)
{
return
2
*
arg
;
}
};
System
.
out
.
println
(
a
.
oblicz
(
100
));
// Od Java 8 można używać "wyrażeń lambda"
FunkcjaLiczbowa
f
=
x
->
x
*
x
;
System
.
out
.
println
(
f
.
oblicz
(
5
));
FunkcjaLiczbowa
silnia
=
(
double
x
)
->
{
double
wynik
=
x
;
for
(
int
i
=
1
;
i
<
x
;
i
++)
{
wynik
*=
i
;
}
return
wynik
;
};
System
.
out
.
println
(
silnia
.
oblicz
(
5
));
double
[]
liczby
=
{
1
,
0
,
5
,
9
,
4
,
1.25
,
0.333
};
System
.
out
.
println
(
Arrays
.
toString
(
liczby
));
Operacje
.
zmienTablice
(
liczby
,
f
);
System
.
out
.
println
(
Arrays
.
toString
(
liczby
));
Operacje
.
zmienTablice
(
liczby
,
x
->
Math
.
sqrt
(
x
));
Operacje
.
zmienTablice
(
liczby
,
Math:
:
sqrt
);
System
.
out
.
println
(
Arrays
.
toString
(
liczby
));
Operacje
.
zmienTablice
(
liczby
,
x
->
10
*
x
);
System
.
out
.
println
(
Arrays
.
toString
(
liczby
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment