Skip to content

Commit

Permalink
remove all mentions of Fragments type alias
Browse files Browse the repository at this point in the history
  • Loading branch information
jdtournier committed Jan 22, 2025
1 parent 3f79050 commit 75f0463
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 109 deletions.
69 changes: 17 additions & 52 deletions week2A.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,9 @@ This is what our `fragments.h` file should look like:
#include <vector>
#include <string>
using Fragments = std::vector<std::string>;
std::vector<std::string> load_fragments (const std::string& filename);
Fragments load_fragments (const std::string& filename);
void fragment_statistics (const Fragments& fragments);
void fragment_statistics (const std::vector<std::string>& fragments);
void write_sequence (const std::string& filename, const std::string& sequence);
```
Expand All @@ -164,11 +162,9 @@ This is what our `fragments.h` file should look like:
#include <vector>
#include <string>
using Fragments = std::vector<std::string>;
Fragments load_fragments (const std::string& filename);
std::vector<std::string> load_fragments (const std::string& filename);
void fragment_statistics (const Fragments& fragments);
void fragment_statistics (const std::vector<std::string>& fragments);
void write_sequence (const std::string& filename, const std::string& sequence);
```
Expand All @@ -192,11 +188,9 @@ This is what our `fragments.h` file should look like:
*#include <vector>
*#include <string>
using Fragments = std::vector<std::string>;
std::vector<std::string> load_fragments (const std::string& filename);
Fragments load_fragments (const std::string& filename);
void fragment_statistics (const Fragments& fragments);
void fragment_statistics (const std::vector<std::string>& fragments);
void write_sequence (const std::string& filename, const std::string& sequence);
```
Expand All @@ -223,38 +217,9 @@ This is what our `fragments.h` file should look like:
#include <vector>
#include <string>
*using Fragments = std::vector<std::string>;
Fragments load_fragments (const std::string& filename);
void fragment_statistics (const Fragments& fragments);
void write_sequence (const std::string& filename, const std::string& sequence);
```


.explain-bottom[
We also include our type alias &ndash; otherwise the compiler won't know what
we mean by `Fragments`
]

---

# Splitting projects over multiple files

This is what our `fragments.h` file should look like:

```
#pragma once
#include <vector>
#include <string>
using Fragments = std::vector<std::string>;
*Fragments load_fragments (const std::string& filename);
*std::vector<std::string> load_fragments (const std::string& filename);
*
*void fragment_statistics (const Fragments& fragments);
*void fragment_statistics (const std::vector<std::string>& fragments);
*
*void write_sequence (const std::string& filename, const std::string& sequence);
```
Expand All @@ -280,11 +245,11 @@ This is what our `fragments.cpp` file should look like:
#include "fragments.h"
Fragments load_fragments (const std::string& filename)
std::vector<std::string> load_fragments (const std::string& filename)
{ ...
}
void fragment_statistics (const Fragments& fragments)
void fragment_statistics (const std::vector<std::string>& fragments)
{ ...
}
Expand All @@ -306,11 +271,11 @@ This is what our `fragments.cpp` file should look like:
#include "fragments.h"
Fragments load_fragments (const std::string& filename)
std::vector<std::string> load_fragments (const std::string& filename)
{ ...
}
void fragment_statistics (const Fragments& fragments)
void fragment_statistics (const std::vector<std::string>& fragments)
{ ...
}
Expand All @@ -337,11 +302,11 @@ This is what our `fragments.cpp` file should look like:
*#include "fragments.h"
Fragments load_fragments (const std::string& filename)
std::vector<std::string> load_fragments (const std::string& filename)
{ ...
}
void fragment_statistics (const Fragments& fragments)
void fragment_statistics (const std::vector<std::string>& fragments)
{ ...
}
Expand All @@ -368,11 +333,11 @@ This is what our `fragments.cpp` file should look like:
#include "fragments.h"
*Fragments load_fragments (const std::string& filename)
*std::vector<std::string> load_fragments (const std::string& filename)
*{ ...
*}
*
*void fragment_statistics (const Fragments& fragments)
*void fragment_statistics (const std::vector<std::string>& fragments)
*{ ...
*}
*
Expand Down Expand Up @@ -1851,7 +1816,7 @@ Exercise: add a function to your code to:
# Possible solution

```
std::string extract_longest_fragment (Fragments& fragments)
std::string extract_longest_fragment (std::vector<std::string>& fragments)
{
unsigned int size_of_longest = 0;
unsigned int index_of_longest = 0;
Expand Down
8 changes: 4 additions & 4 deletions week2B.md
Original file line number Diff line number Diff line change
Expand Up @@ -2195,7 +2195,7 @@ We now have all the pieces required to implement our verbose option
For example, in `fragments.cpp`:
```
...
Fragments load_fragments (const std::string& filename)
std::vector<std::string> load_fragments (const std::string& filename)
{
* if (debug::verbose)
std::cerr << "reading fragments from file \"" << filename << "\"...\n";
Expand All @@ -2204,7 +2204,7 @@ Fragments load_fragments (const std::string& filename)

--

.explain-bottom[
.explain-bottomright[
Exercise: implement these changes in your own code
]

Expand Down Expand Up @@ -2380,7 +2380,7 @@ mentioned above, the compiler is free to treat this merely as a *hint*
We can now use our convenience function in our code, for example in `fragments.cpp`:
```
...
Fragments load_fragments (const std::string& filename)
std::vector<std::string> load_fragments (const std::string& filename)
{
* if (debug::verbose)
* std::cerr << "reading fragments from file \"" << filename << "\"...\n";
Expand All @@ -2389,7 +2389,7 @@ Fragments load_fragments (const std::string& filename)
becomes simply:
```
...
Fragments load_fragments (const std::string& filename)
std::vector<std::string> load_fragments (const std::string& filename)
{
* debug::log ("reading fragments from file \"" + filename + "\"...");
...
Expand Down
Loading

0 comments on commit 75f0463

Please sign in to comment.