-
Notifications
You must be signed in to change notification settings - Fork 0
/
objects.h
44 lines (36 loc) · 1.21 KB
/
objects.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdlib.h>
#define TWEET_LENGTH 280
#define USERNAME_LENGTH 100
#define FOLLOW_MAX 30
#ifndef OBJECTS
#define OBJECTS
typedef struct tweet {
size_t userID; /* unique ID of tweet's author in userlist */
char tweetAuthor[USERNAME_LENGTH]; /* While storing the tweet's author here does waste memory, it makes it much easier to access. */
char tweet[TWEET_LENGTH];
} tweet;
typedef struct user {
char username[USERNAME_LENGTH];
size_t userID;
size_t followers[FOLLOW_MAX]; /* collection of userID's */
size_t follower_count; /* need to check if < FOLLOW_MAX before adding to followers[] */
size_t following[FOLLOW_MAX];
size_t following_count;
} user;
typedef struct TweetNode {
tweet tweet;
struct TweetNode *next; /* link to previously most recent tweet */
} TweetNode;
typedef struct UserNode {
user *user;
struct UserNode *next;
struct UserNode *previous;
} UserNode;
typedef struct twitter {
UserNode *userlist; /* start of userlist */
size_t user_count;
UserNode *current_user; /* pointer to current usernode */
TweetNode *most_recent_tweet; /* Probably want to change the name
of this (start of the linked list) */
} twitter;
#endif