Exemple #1
0
		bool insert(KEY key, PAD pad)
		{
			if(size_ >= SIZE) return false;

			uint32_t i = 0;
			if(key >= cen_key_) i = cen_org_;

			while(i < size_) {
				if(key < core_[i].key) {
					move_(i);
					break;
				} else if(key == core_[i].key) {
					++core_[i].pad;
					return true;
				}
				++i;
			}
			core_[i].key = key;
			core_[i].pad = 1;
			++size_;

			cen_key_ = core_[size_ / 2].key;
			cen_org_ = size_ / 2;
			return false;
		}
Exemple #2
0
Optional<String>
readFile(String& path) noexcept {
    Optional<uint64_t> size = getFileSize(path);
    if (!size) {
        return Optional<String>();
    }

    FILE* f = fopen(path.null(), "r");
    if (!f) {
        return Optional<String>();
    }

    String contents;
    contents.resize(*size);

    ssize_t read = fread(contents.data(), *size, 1, f);
    if (read != 1) {
        fclose(f);
        return Optional<String>();
    }

    fclose(f);

    return Optional<String>(move_(contents));
}
Exemple #3
0
void GosuMusic::play(std::string filepath) {
    if (path == filepath) {
        if (musicInst->paused()) {
            paused = 0;
            musicInst->play(true);
        }
        return;
    }

    MusicWorker::play(move_(filepath));
    TimeMeasure m("Playing " + path);
    if (musicInst && musicInst->playing()) {
        musicInst->stop();
    }
    musicInst = path.size() ? songs.lifetimeRequest(path)
                            : Rc<Gosu::Song>();
    musicInst->play(true);
    musicInst->set_volume(volume);
}
Exemple #4
0
int maklin (char lin[], int i, LINEDESC **newind)
{

	char text [MAXLINE];
	int l, n;
	LINEDESC *ptr;

	if (alloc (&ptr) == SE_NOMORE)     /* get space for pointer block */
		return (SE_ERR);

	for (n = i; lin [n] != SE_EOS; n++)	/* find end of line */
		if (lin [n] == '\n')
		{
			n++;
			break;
		}

	if (n - i >= MAXLINE )  /* can't handle more than MAXLINE chars/line */
		n = i + MAXLINE - 1;
	l = n - i + 1;          /* length of new line (including SE_EOS) */

	move_ (&lin [i], text, l);      /* move new line into text */
	text [l - 1] = SE_EOS;             /* add SE_EOS */

	ptr->Seekaddr = Scrend; /* will be added to end of scratch file */
	ptr->Lineleng = l;      /* line length including SE_EOS */
	ptr->Globmark = SE_NO;     /* not marked for Global command */
	ptr->Markname = DEFAULTNAME;    /* give it default mark name */

	seekf ((long) Scrend * 8, Scr); /* go to end of scratch file */
	writef (text, l, Scr);          /* write line on scratch file */
	Scrend += (l + 7) / 8;          /* update end-of-file pointer */

	Buffer_changed = SE_YES;

	*newind = ptr;                  /* return index of new line */
	return (n);                     /* return next char of interest in lin */
}
Exemple #5
0
Exit::Exit(String area, int x, int y, double z) noexcept
        : area(move_(area)), coords{x, y, z} {}