define(["require", "exports", "./../collections/dictionary"], function (require, exports, dictionary_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PdfCacheCollection = (function () {
function PdfCacheCollection() {
this.referenceObjects = [];
this.pdfFontCollection = new dictionary_1.Dictionary();
}
PdfCacheCollection.prototype.search = function (obj) {
var result = null;
var group = this.getGroup(obj);
Eif (group == null) {
group = this.createNewGroup();
}
else if (group.length > 0) {
result = group[0];
}
group.push(obj);
return result;
};
PdfCacheCollection.prototype.createNewGroup = function () {
var group = [];
this.referenceObjects.push(group);
return group;
};
PdfCacheCollection.prototype.getGroup = function (result) {
var group = null;
Eif (result !== null) {
var len = this.referenceObjects.length;
for (var i = 0; i < len; i++) {
if (this.referenceObjects.length > 0) {
var tGroup = this.referenceObjects[i];
if (tGroup.length > 0) {
var representative = tGroup[0];
if (result.equalsTo(representative)) {
group = tGroup;
break;
}
}
else {
this.removeGroup(tGroup);
}
}
len = this.referenceObjects.length;
}
}
return group;
};
PdfCacheCollection.prototype.removeGroup = function (group) {
if (group !== null) {
var index = this.referenceObjects.indexOf(group);
this.referenceObjects.slice(index, index + 1);
}
};
PdfCacheCollection.prototype.destroy = function () {
this.pdfFontCollection = undefined;
this.referenceObjects = undefined;
};
return PdfCacheCollection;
}());
exports.PdfCacheCollection = PdfCacheCollection;
});
|