File tree 4 files changed +24
-0
lines changed
4 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -6,5 +6,6 @@ In questo repository puoi trovare buona parte del codice in cui si parla del lib
6
6
7
7
- [ React] [ useTransition()] ( /react/useTransition )
8
8
- [ Next] [ ./app/not-found.tsx] ( /next.js/page-not-found )
9
+ - [ TypeScript] [ generics] ( /typescript/generics )
9
10
10
11
...
Original file line number Diff line number Diff line change
1
+ * .js
Original file line number Diff line number Diff line change
1
+ class Coda < T > {
2
+ private items : T [ ] = [ ] ;
3
+
4
+ aggiungi ( item : T ) : void {
5
+ this . items . push ( item ) ;
6
+ }
7
+
8
+ togli ( ) : T | undefined {
9
+ return this . items . shift ( ) ;
10
+ }
11
+
12
+ dimensione ( ) : number {
13
+ return this . items . length ;
14
+ }
15
+ }
16
+
17
+ const numberQueue = new Coda < number > ( ) ;
18
+ numberQueue . aggiungi ( 10 ) ;
19
+ numberQueue . aggiungi ( 20 ) ;
20
+ numberQueue . aggiungi ( 30 ) ;
21
+ console . log ( numberQueue . togli ( ) ) ;
22
+ console . log ( numberQueue . dimensione ( ) ) ;
You can’t perform that action at this time.
0 commit comments