Inserts a new, blank record somewhere in the page. Return false if there
were no available slots.

@return false if the insertion was not possible
172360
public boolean insertIntoNextEmptySlot() {
		boolean found = searchFor(EMPTY);
		if (found) {
			Constant flag = INUSE_CONST;
			setVal(currentPos(), flag);
		}
		return found;
	}
893129
@Override
    public boolean next() {
        if (pointer < rows.size() && pointer + 1 != rows.size()) {
            pointer++;
            currentRecord = new RowRecord(rows.get(pointer), metaData, parser.isColumnNamesCaseSensitive(), pzConvertProps, strictNumericParse,
                    upperCase, lowerCase, parser.isNullEmptyStrings());
            return true;
        }
        currentRecord = null;
        return false;
    }
644205
public function save() :bool {
		
		// if an id already exists
		if($this->_['id']) {
			// we can update and return the number of affected rows (0 on error, 1 on success)
			return (bool) self::_update()
				->set($this->__toArray(true, true))
				->where(['id'=>$this->_['id']])
				->execute();
		}
		// this is a new record
		else {
			// try to insert it
			$inserted_object = self::create($this->__toArray(true, true));
			// if insertion succeeded, return true
			if($inserted_object) {
				// clone ourselves with what the database returneds, a full fledged object
				$this->replicate($inserted_object);
				// return success
				return true;
			}
			// didnt insert
			else {
				// failure feedback
				return false;
			}
		}
		
	}
997791
def insert(self):
        """"""
        ret = True

        schema = self.schema
        fields = self.depopulate(False)

        q = self.query
        q.set_fields(fields)
        pk = q.insert()
        if pk:
            fields = q.fields
            fields[schema.pk.name] = pk
            self._populate(fields)

        else:
            ret = False

        return ret
1304347
public int insert(Connection conn, Entity record) throws SQLException {
		checkConn(conn);
		if(CollectionUtil.isEmpty(record)){
			throw new SQLException("Empty entity provided!");
		}
		PreparedStatement ps = null;
		try {
			ps = dialect.psForInsert(conn, record);
			return ps.executeUpdate();
		} catch (SQLException e) {
			throw e;
		} finally {
			DbUtil.close(ps);
		}
	}
185168
private boolean insertIndexEntry(final S userStorable, final Storable indexEntry)
        throws PersistException
    {
        if (indexEntry.tryInsert()) {
            return true;
        }

        // If index entry already exists, then index might be corrupt.
        try {
            Storable freshIndexEntry = mIndexEntryStorage.prepare();
            mAccessor.copyFromMaster(freshIndexEntry, userStorable);
            freshIndexEntry.load();
            indexEntry.copyVersionProperty(freshIndexEntry);
            if (freshIndexEntry.equals(indexEntry)) {
                // Existing entry is fine.
                return true;

            } else {
                S freshMasterEntry = mMasterStorage.prepare();
                mAccessor.copyToMasterPrimaryKey(freshIndexEntry, freshMasterEntry);
                
                if (!freshMasterEntry.tryLoad()) {
                    // Existing entry for alternate key is bogus. Delete it.
                    freshIndexEntry.delete();
                    indexEntry.insert();
                    return true;
                }
            }

        } catch (FetchException e) {
            throw e.toPersistException();
        }

        return false;
    }
406315
public boolean insert(int newIndex) {
        // Ignore objects which do not belong in this quad tree
        INDArray point = data.slice(newIndex);
        if (!boundary.containsPoint(point))
            return false;

        cumSize++;
        double mult1 = (double) (cumSize - 1) / (double) cumSize;
        double mult2 = 1.0 / (double) cumSize;

        centerOfMass.muli(mult1);
        centerOfMass.addi(point.mul(mult2));

        // If there is space in this quad tree and it is a leaf, add the object here
        if (isLeaf() && size < QT_NODE_CAPACITY) {
            index[size] = newIndex;
            size++;
            return true;
        }

        //duplicate point
        if (size > 0) {
            for (int i = 0; i < size; i++) {
                INDArray compPoint = data.slice(index[i]);
                if (point.getDouble(0) == compPoint.getDouble(0) && point.getDouble(1) == compPoint.getDouble(1))
                    return true;
            }
        }



        // If this Node has already been subdivided just add the elements to the
        // appropriate cell
        if (!isLeaf()) {
            QuadTree index = findIndex(point);
            index.insert(newIndex);
            return true;
        }

        if (isLeaf())
            subDivide();

        boolean ret = insertIntoOneOf(newIndex);



        return ret;
    }
409593
public boolean hasNext() throws DBException
    {
        Object record = this.next();
        if (record == null)
            return false;
        else
        {
            this.previous();        // Remember, Memory tables are FAAAAST!
            return true;
        }
    }
352065
private function SaveNew()
    {
        $treeBuilder = new TreeBuilder(new PageTreeProvider($this->site));
        $treeBuilder->Insert($this->page, $this->parent, $this->previous);
    }
1066671
public Note instantiateForInsert() {
		Note entity = new Note();
		entity.setIsDeleted(Boolean.FALSE);
		return entity;
	}
927085
public int[] insert(Collection<Entity> records) throws SQLException {
		Connection conn = null;
		try {
			conn = this.getConnection();
			return runner.insert(conn, records);
		} catch (SQLException e) {
			throw e;
		} finally {
			this.closeConnection(conn);
		}
	}
323571
public function insert($page) {
        global $DB;

        $slots = $DB->get_records('quiz_slots', array('quizid' => $this->record->quizid),
                'slot', 'id, slot, page');

        $trans = $DB->start_delegated_transaction();

        $maxpage = 1;
        $numonlastpage = 0;
        foreach ($slots as $slot) {
            if ($slot->page > $maxpage) {
                $maxpage = $slot->page;
                $numonlastpage = 1;
            } else {
                $numonlastpage += 1;
            }
        }

        if (is_int($page) && $page >= 1) {
            // Adding on a given page.
            $lastslotbefore = 0;
            foreach (array_reverse($slots) as $otherslot) {
                if ($otherslot->page > $page) {
                    $DB->set_field('quiz_slots', 'slot', $otherslot->slot + 1, array('id' => $otherslot->id));
                } else {
                    $lastslotbefore = $otherslot->slot;
                    break;
                }
            }
            $this->record->slot = $lastslotbefore + 1;
            $this->record->page = min($page, $maxpage + 1);

            quiz_update_section_firstslots($this->record->quizid, 1, max($lastslotbefore, 1));
        } else {
            $lastslot = end($slots);
            $quiz = $this->get_quiz();
            if ($lastslot) {
                $this->record->slot = $lastslot->slot + 1;
            } else {
                $this->record->slot = 1;
            }
            if ($quiz->questionsperpage && $numonlastpage >= $quiz->questionsperpage) {
                $this->record->page = $maxpage + 1;
            } else {
                $this->record->page = $maxpage;
            }
        }

        $this->record->id = $DB->insert_record('quiz_slots', $this->record);

        if (!empty($this->tags)) {
            $recordstoinsert = [];
            foreach ($this->tags as $tag) {
                $recordstoinsert[] = (object)[
                    'slotid' => $this->record->id,
                    'tagid' => $tag->id,
                    'tagname' => $tag->name
                ];
            }
            $DB->insert_records('quiz_slot_tags', $recordstoinsert);
        }

        $trans->allow_commit();
    }
446996
@Override
	public boolean insert(T entity) {
		if(entity == null) {
			return false;
		}
		
		X primaryID = getPrimaryID(entity);
		if(primaryID != null) {
			if(!allowEmptyOrZeroID() && AssertUtils.isEmpty(primaryID)) {
				return false;
			}
		}

		try {
		    this.mongoTemplate.insert(entity);
		} catch(RuntimeException e) {
		    // this ensures that any insert operation that fails returns a false
		    return false;
		}
		
		return true;
	}
458726
protected function _insert()
    {
        if ($this->oxcategories__oxparentid->value != "oxrootid") {
            // load parent
            $oParent = oxNew(\OxidEsales\Eshop\Application\Model\Category::class);
            //#M317 check if parent is loaded
            if (!$oParent->load($this->oxcategories__oxparentid->value)) {
                return false;
            }

            $sAdd = " and oxshopid = '" . $this->getShopId() . "' ";

            // update existing nodes
            $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
            $oDb->execute(
                "UPDATE oxcategories SET OXLEFT = OXLEFT + 2
                                           WHERE  OXROOTID = " . $oDb->quote($oParent->oxcategories__oxrootid->value) . "
                            AND OXLEFT >   " . ((int) $oParent->oxcategories__oxright->value) . "
                            AND OXRIGHT >= " . ((int) $oParent->oxcategories__oxright->value) . $sAdd
            );


            $oDb->execute(
                "UPDATE oxcategories SET OXRIGHT = OXRIGHT + 2
                                           WHERE  OXROOTID = " . $oDb->quote($oParent->oxcategories__oxrootid->value) . "
                            AND OXRIGHT >= " . ((int) $oParent->oxcategories__oxright->value) . $sAdd
            );

            if (!$this->getId()) {
                $this->setId();
            }

            $this->oxcategories__oxrootid = new \OxidEsales\Eshop\Core\Field($oParent->oxcategories__oxrootid->value, \OxidEsales\Eshop\Core\Field::T_RAW);
            $this->oxcategories__oxleft = new \OxidEsales\Eshop\Core\Field($oParent->oxcategories__oxright->value, \OxidEsales\Eshop\Core\Field::T_RAW);
            $this->oxcategories__oxright = new \OxidEsales\Eshop\Core\Field($oParent->oxcategories__oxright->value + 1, \OxidEsales\Eshop\Core\Field::T_RAW);

            return parent::_insert();
        } else {
            // root entry
            if (!$this->getId()) {
                $this->setId();
            }

            $this->oxcategories__oxrootid = new \OxidEsales\Eshop\Core\Field($this->getId(), \OxidEsales\Eshop\Core\Field::T_RAW);
            $this->oxcategories__oxleft = new \OxidEsales\Eshop\Core\Field(1, \OxidEsales\Eshop\Core\Field::T_RAW);
            $this->oxcategories__oxright = new \OxidEsales\Eshop\Core\Field(2, \OxidEsales\Eshop\Core\Field::T_RAW);

            return parent::_insert();
        }
    }
61047
@Override
    public void insert(Session session, PersistentStore store, Row row) {

        NodeAVL n;
        NodeAVL x;
        boolean isleft  = true;
        int     compare = -1;

        writeLock.lock();

        try {
            n = getAccessor(store);
            x = n;

            if (n == null) {
                store.setAccessor(this, ((RowAVL) row).getNode(position));

                return;
            }

            while (true) {
                Row currentRow = n.getRow(store);

                compare = compareRowForInsertOrDelete(session, row,
                                                      currentRow);

                if (compare == 0) {
                    throw Error.error(ErrorCode.X_23505);
                }

                isleft = compare < 0;
                x      = n;
                n      = child(store, x, isleft);

                if (n == null) {
                    break;
                }
            }

            x = set(store, x, isleft, ((RowAVL) row).getNode(position));

            balance(store, x, isleft);
        } finally {
            writeLock.unlock();
        }
    }
365242
public boolean newPage() {
        lastElementType = -1;
        if (isPageEmpty()) {
        	setNewPageSizeAndMargins();
            return false;
        }
    	if (!open || close) {
    		throw new RuntimeException("The document isn't open.");
    	}
        PdfPageEvent pageEvent = writer.getPageEvent();
        if (pageEvent != null)
            pageEvent.onEndPage(writer, this);

        //Added to inform any listeners that we are moving to a new page (added by David Freels)
        super.newPage();

        // the following 2 lines were added by Pelikan Stephan
        indentation.imageIndentLeft = 0;
        indentation.imageIndentRight = 0;

        try {
            // we flush the arraylist with recently written lines
        	flushLines();

        	// we prepare the elements of the page dictionary

        	// [U1] page size and rotation
        	int rotation = pageSize.getRotation();

        	// [C10]
        	if (writer.isPdfX()) {
        		if (thisBoxSize.containsKey("art") && thisBoxSize.containsKey("trim"))
        			throw new PdfXConformanceException("Only one of ArtBox or TrimBox can exist in the page.");
        		if (!thisBoxSize.containsKey("art") && !thisBoxSize.containsKey("trim")) {
        			if (thisBoxSize.containsKey("crop"))
        				thisBoxSize.put("trim", thisBoxSize.get("crop"));
        			else
        				thisBoxSize.put("trim", new PdfRectangle(pageSize, pageSize.getRotation()));
        		}
        	}

        	// [M1]
        	pageResources.addDefaultColorDiff(writer.getDefaultColorspace());
            if (writer.isRgbTransparencyBlending()) {
                PdfDictionary dcs = new PdfDictionary();
                dcs.put(PdfName.CS, PdfName.DEVICERGB);
                pageResources.addDefaultColorDiff(dcs);
            }
        	PdfDictionary resources = pageResources.getResources();

        	// we create the page dictionary

        	PdfPage page = new PdfPage(new PdfRectangle(pageSize, rotation), thisBoxSize, resources, rotation);
        	page.put(PdfName.TABS, writer.getTabs());

            // we complete the page dictionary

            // [C9] if there is XMP data to add: add it
            if (xmpMetadata != null) {
            	PdfStream xmp = new PdfStream(xmpMetadata);
            	xmp.put(PdfName.TYPE, PdfName.METADATA);
            	xmp.put(PdfName.SUBTYPE, PdfName.XML);
            	PdfEncryption crypto = writer.getEncryption();
                if (crypto != null && !crypto.isMetadataEncrypted()) {
                    PdfArray ar = new PdfArray();
                    ar.add(PdfName.CRYPT);
                    xmp.put(PdfName.FILTER, ar);
                }
            	page.put(PdfName.METADATA, writer.addToBody(xmp).getIndirectReference());
            }

        	// [U3] page actions: transition, duration, additional actions
        	if (this.transition!=null) {
        		page.put(PdfName.TRANS, this.transition.getTransitionDictionary());
        		transition = null;
        	}
        	if (this.duration>0) {
        		page.put(PdfName.DUR,new PdfNumber(this.duration));
        		duration = 0;
        	}
        	if (pageAA != null) {
        		page.put(PdfName.AA, writer.addToBody(pageAA).getIndirectReference());
        		pageAA = null;
        	}

        	// [U4] we add the thumbs
        	if (thumb != null) {
        		page.put(PdfName.THUMB, thumb);
        		thumb = null;
        	}

        	// [U8] we check if the userunit is defined
        	if (writer.getUserunit() > 0f) {
        		page.put(PdfName.USERUNIT, new PdfNumber(writer.getUserunit()));
        	}

        	// [C5] and [C8] we add the annotations
        	if (annotationsImp.hasUnusedAnnotations()) {
        		PdfArray array = annotationsImp.rotateAnnotations(writer, pageSize);
        		if (array.size() != 0)
        			page.put(PdfName.ANNOTS, array);
        	}

        	// [F12] we add tag info
        	if (writer.isTagged())
        		page.put(PdfName.STRUCTPARENTS, new PdfNumber(writer.getCurrentPageNumber() - 1));

            if (text.size() > textEmptySize)
        		text.endText();
        	else
        		text = null;
        	writer.add(page, new PdfContents(writer.getDirectContentUnder(), graphics, text, writer.getDirectContent(), pageSize));
        	// we initialize the new page
        	initPage();
        }
        catch(DocumentException de) {
        	// maybe this never happens, but it's better to check.
        	throw new ExceptionConverter(de);
        }
        catch (IOException ioe) {
            throw new ExceptionConverter(ioe);
        }
        return true;
    }
319164
function save()
    {
        if ($this->id != false || $this->id != 0) {
            return $this->update();
        } else {
            return $this->insert();
        }
    }