- Accounts(memberID, fName, 1Name, email, creditCardNo, password) - CreatesProfiles
(memberID, name, gender, dob ) - pGenres (memberID, name, genre) - Movies ( movieID, title,
yearOfRelease, lengthInMinutes, avgRating) - MGenres ( movieID, genre ) - Streams ( movieID,
memberID, name, rating, dateTimeWatched) - Directors ( dID, fName, 1Name, dob) - Directs
(movieID, dID) - Actors (aID, fName, 1Name, gender) - Casts ( movieID, aID, role) The primary
keys are underlined. The referential integrity constraints are as follows: - the column memberID of
relation CreatesProfiles that references table Accounts, - the columns memberID and name of
relation pG Genres that references table CreatesProfiles, - the column movieID of relation
MGenres that references table Movies, - the column movieID of relation Streams that references
table Movies, - the columns memberID and name of relation Streams that references table
CreatesProfiles, - the column movieID of relation Directs that references table Movies, - the
column dID of relation Directs that references table Directors, - the column movieID of relation
Casts that references table Movies, and - the column alD of relation Casts that references table
Actors. The following query is intended to list the ID of directors for Action films. However, this
query does not work properly. Briefly explain why: and show the corrected SQL query SELECT
DISTINCT dID FROM MGenres M, Directs D ON (M.movieID = D.movieID) WHERE genre =
'Action';.
for initializer_list include ltinitializer_listgt .pdf
1. // for initializer_list
#include <initializer_list>
// for ostream
#include <iostream>
// for bidirectional_iterator_tag, prev, next, distance
#include <iterator>
// for ptrdiff_t, size_t, swap
#include <utility>
/************************************************************/
// struct representing our ListNode
//
// contains three data members:
// - data
// - next
// - prev
template<typename T>
struct ListNode
{
ListNode () : data ()
{
}
ListNode (const T& v) : data (v)
{
}
ListNode (const T& v, ListNode* n, ListNode* p) : data (v), next (n), prev (p)
{
}
// unhooks the range [begin,end] from a linked list
// NOTE: will lose reference to begin and end if you
// are not keeping track of it!
//
// - does not create any new nodes
// - does not destroy any existing nodes
// - begin is start of range to remove
// - end is inclusive end of range to remove
//
// [5]
static void
unhook_range (ListNode* begin, ListNode* end)
{
if (begin == nullptr || end == nullptr)
{
2. return;
}
if (begin == end)
{
return;
}
if (begin->prev != nullptr)
{
begin->prev->next = end->next;
}
if (end->next != nullptr)
{
end->next->prev = begin->prev;
}
begin->prev = nullptr;
end->next = nullptr;
}
// inserts the range [first,last] before this
// NOTE: does not create any new nodes, does not destroy any existing nodes
//
// [5]
void
hook_range (ListNode* first, ListNode* last)
{
if (first == nullptr || last == nullptr)
{
return;
}
unhook();
if (first == last)
{
first->prev = this;
last->next = this;
next = first;
prev = last;
} else
{
ListNode* before_first = first->prev;
ListNode* after_last = last->next;
before_first->next = first;
first->prev = before_first;
last->next = after_last;
3. after_last->prev = last;
next = first;
prev = last;
}
}
// insert first before this
void
hook (ListNode* first)
{
hook_range (first, first);
}
// unhooks current node from linked list
void
unhook ()
{
ListNode::unhook_range (this, this);
}
T data;
ListNode* next{nullptr};
ListNode* prev{nullptr};
};
/************************************************************/
// Struct representing a List const_iterator
//
// contains a single data member:
// - m_nodePtr
template<typename T>
struct ListConstIterator
{
using value_type = T;
using pointer = const value_type*;
using reference = const value_type&;
using difference_type = std::ptrdiff_t;
using iterator_category = std::bidirectional_iterator_tag;
using Node = const ListNode<value_type>;
public:
// construct from Node
ListConstIterator (Node* n) : m_nodePtr (n)
{
}
// construct from Iterator
ListConstIterator (const ListIterator<T>& i) : m_nodePtr (i.m_nodePtr)
5. <> (const ListConstIterator& i, const ListConstIterator& j);
friend bool operator!=
<> (const ListConstIterator& i, const ListConstIterator& j);
private:
Node* m_nodePtr{nullptr};
friend class List<T>;
friend class ListIterator<T>;
};
template<typename T>
bool
operator== (const ListConstIterator<T>& i, const ListConstIterator<T>& j)
{
return i.m_nodePtr == j.m_nodePtr;
}
// compares the underlying pointers for equality
// [2]
template<typename T>
bool
operator!= (const ListConstIterator<T>& i, const ListConstIterator<T>& j)
{
// TODO -- be sure to not accidently make this an infinite recursive call!
}
/************************************************************/
// Struct representing a List iterator
//
// contains a single data member:
// - m_nodePtr
template<typename T>
struct ListIterator
{
using value_type = T;
using pointer = value_type*;
using reference = value_type&;
using difference_type = std::ptrdiff_t;
using iterator_category = std::bidirectional_iterator_tag;
using Node = ListNode<value_type>;
public:
// construct from Node
ListIterator (Node* n) : m_nodePtr (n)
{
}
reference operator* () const
6. {
return m_nodePtr->data;
}
pointer operator-> () const
{
return &(m_nodePtr->data);
}
// advances to the "next" pointer, returns reference to self
// [2]
ListIterator&
operator++ ()
{
// TODO
}
// advances to the "next" pointer, returns copy of self prior to advancement
ListIterator
operator++ (int)
{
ListIterator copy (*this);
m_nodePtr = m_nodePtr->next;
return copy;
}
// advances to the "prev" pointer, returns reference to self
ListIterator&
operator-- ()
{
m_nodePtr = m_nodePtr->prev;
return *this;
}
// advances to the "prev" pointer, returns copy of self prior to advancement
// [2]
ListIterator
operator-- (int)
{
// TODO
}
friend bool operator==<> (const ListIterator& i, const ListIterator& j);
friend bool operator!=<> (const ListIterator& i, const ListIterator& j);
private:
Node* m_nodePtr{nullptr};
friend class List<T>;
friend class ListConstIterator<T>;
7. };
// compares the underlying pointers for equality
// [2]
template<typename T>
bool
operator== (const ListIterator<T>& i, const ListIterator<T>& j)
{
// TODO -- be sure to not accidently make this an infinite recursive call!
}
template<typename T>
bool
operator!= (const ListIterator<T>& i, const ListIterator<T>& j)
{
return i.m_nodePtr != j.m_nodePtr;
}
Please complete the implementation for the missing parts marked TODO!