Java 类com.badlogic.gdx.utils.LongMap 实例源码

项目:gdx-cclibs    文件:LongMapSerializer.java   
public void write (Kryo kryo, Output output, LongMap map) {
    int length = map.size;
    output.writeVarInt(length, true);
    output.writeBoolean(false); // whether type is written (in case future version of LongMap supports type awareness)

    Serializer valueSerializer = null;
    if (valueGenericType != null) {
        if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueGenericType);
        valueGenericType = null;
    }

    for (Iterator iter = map.iterator(); iter.hasNext();) {
        LongMap.Entry entry = (LongMap.Entry)iter.next();
        output.writeLong(entry.key);
        if (valueSerializer != null) {
            kryo.writeObjectOrNull(output, entry.value, valueSerializer);
        } else
            kryo.writeClassAndObject(output, entry.value);
    }
}
项目:gdx-cclibs    文件:LongMapSerializer.java   
public LongMap read (Kryo kryo, Input input, Class<LongMap> type) {
    int length = input.readVarInt(true);
    input.readBoolean(); // currently unused
    LongMap map = new LongMap(length);

    Class valueClass = null;

    Serializer valueSerializer = null;
    if (valueGenericType != null) {
        valueClass = valueGenericType;
        if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueClass);
        valueGenericType = null;
    }

    kryo.reference(map);

    for (int i = 0; i < length; i++) {
        long key = input.readLong();
        Object value;
        if (valueSerializer != null) {
            value = kryo.readObjectOrNull(input, valueClass, valueSerializer);
        } else
            value = kryo.readClassAndObject(input);
        map.put(key, value);
    }
    return map;
}
项目:Undertailor    文件:OpenALAudio.java   
public OpenALAudio (int simultaneousSources, int deviceBufferCount, int deviceBufferSize) {
    this.deviceBufferSize = deviceBufferSize;
    this.deviceBufferCount = deviceBufferCount;

    registerSound("ogg", Ogg.Sound.class);
    registerMusic("ogg", Ogg.Music.class);
    registerSound("wav", Wav.Sound.class);
    registerMusic("wav", Wav.Music.class);
    registerSound("mp3", Mp3.Sound.class);
    registerMusic("mp3", Mp3.Music.class);

    try {
        AL.create();
    } catch (LWJGLException ex) {
        noDevice = true;
        ex.printStackTrace();
        return;
    }

    allSources = new IntArray(false, simultaneousSources);
    for (int i = 0; i < simultaneousSources; i++) {
        int sourceID = alGenSources();
        if (alGetError() != AL_NO_ERROR) break;
        allSources.add(sourceID);
    }
    idleSources = new IntArray(allSources);
    soundIdToSource = new LongMap<Integer>();
    sourceToSoundId = new IntMap<Long>();

    FloatBuffer orientation = (FloatBuffer)BufferUtils.createFloatBuffer(6)
        .put(new float[] {0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f}).flip();
    alListener(AL_ORIENTATION, orientation);
    FloatBuffer velocity = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip();
    alListener(AL_VELOCITY, velocity);
    FloatBuffer position = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip();
    alListener(AL_POSITION, position);

    recentSounds = new OpenALSound[simultaneousSources];
}
项目:gdx-backend-jglfw    文件:OpenALAudio.java   
public OpenALAudio (int simultaneousSources, int deviceBufferCount, int deviceBufferSize) {
    this.deviceBufferSize = deviceBufferSize;
    this.deviceBufferCount = deviceBufferCount;

    registerSound("ogg", Ogg.Sound.class);
    registerMusic("ogg", Ogg.Music.class);
    registerSound("wav", Wav.Sound.class);
    registerMusic("wav", Wav.Music.class);
    registerSound("mp3", Mp3.Sound.class);
    registerMusic("mp3", Mp3.Music.class);

    alContext = ALContext.create();

    allSources = new IntArray(false, simultaneousSources);
    for (int i = 0; i < simultaneousSources; i++) {
        int sourceID = alGenSources();
        if (alGetError() != AL_NO_ERROR) break;
        allSources.add(sourceID);
    }
    idleSources = new IntArray(allSources);
    soundIdToSource = new LongMap<Integer>();
    sourceToSoundId = new IntMap<Long>();

    FloatBuffer orientation = (FloatBuffer)BufferUtils.createFloatBuffer(6)
        .put(new float[] {0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f}).flip();
    alListenerfv(AL_ORIENTATION, orientation);
    FloatBuffer velocity = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip();
    alListenerfv(AL_VELOCITY, velocity);
    FloatBuffer position = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip();
    alListenerfv(AL_POSITION, position);

    recentSounds = new OpenALSound[simultaneousSources];
}
项目:CodeBase    文件:SoundInstance.java   
public static void init() {
    try {
        Field field = OpenALAudio.class.getDeclaredField("soundIdToSource");
        field.setAccessible(true);
        soundIdToSource = (LongMap<Integer>) field.get(Gdx.audio);
    } catch (Exception e) {
        throw new RuntimeException("Error getting soundIdToSource", e);
    }
}
项目:libgdxcn    文件:OpenALAudio.java   
public OpenALAudio (int simultaneousSources, int deviceBufferCount, int deviceBufferSize) {
    this.deviceBufferSize = deviceBufferSize;
    this.deviceBufferCount = deviceBufferCount;

    registerSound("ogg", Ogg.Sound.class);
    registerMusic("ogg", Ogg.Music.class);
    registerSound("wav", Wav.Sound.class);
    registerMusic("wav", Wav.Music.class);
    registerSound("mp3", Mp3.Sound.class);
    registerMusic("mp3", Mp3.Music.class);

    try {
        AL.create();
    } catch (LWJGLException ex) {
        noDevice = true;
        ex.printStackTrace();
        return;
    }

    allSources = new IntArray(false, simultaneousSources);
    for (int i = 0; i < simultaneousSources; i++) {
        int sourceID = alGenSources();
        if (alGetError() != AL_NO_ERROR) break;
        allSources.add(sourceID);
    }
    idleSources = new IntArray(allSources);
    soundIdToSource = new LongMap<Integer>();
    sourceToSoundId = new IntMap<Long>();

    FloatBuffer orientation = (FloatBuffer)BufferUtils.createFloatBuffer(6)
        .put(new float[] {0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f}).flip();
    alListener(AL_ORIENTATION, orientation);
    FloatBuffer velocity = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip();
    alListener(AL_VELOCITY, velocity);
    FloatBuffer position = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip();
    alListener(AL_POSITION, position);

    recentSounds = new OpenALSound[simultaneousSources];
}
项目:Undertailor    文件:Scheduler.java   
public Scheduler(Environment env) {
    this.env = env;
    this.destroyed = false;
    this.tasks = new LongMap<>();
    this.activeTasks = new OrderedMap<>();
}
项目:GdxDemo3D    文件:Engine.java   
public Engine(){
    entities = new Array<Entity>(false, 16);
    entitiesById = new LongMap<Entity>();
}
项目:libGDX-LWJGL-Audio    文件:OpenALAudio.java   
public OpenALAudio(int simultaneousSources, int deviceBufferCount, int deviceBufferSize) {
    this.deviceBufferSize = deviceBufferSize;
    this.deviceBufferCount = deviceBufferCount;

    registerSound("ogg", Ogg.Sound.class);
    registerMusic("ogg", Ogg.Music.class);
    registerSound("wav", Wav.Sound.class);
    registerMusic("wav", Wav.Music.class);
    registerSound("mp3", Mp3.Sound.class);
    registerMusic("mp3", Mp3.Music.class);

    try {
        AL.create();
    } catch (LWJGLException ex) {
        noDevice = true;
        ex.printStackTrace();
        return;
    }

    allSources = new IntArray(false, simultaneousSources);
    for (int i = 0; i < simultaneousSources; i++) {
        int sourceID = alGenSources();
        if (alGetError() != AL_NO_ERROR) {
            break;
        }
        allSources.add(sourceID);
    }
    idleSources = new IntArray(allSources);
    soundIdToSource = new LongMap<>();
    sourceToSoundId = new IntMap<>();

    FloatBuffer orientation = (FloatBuffer) BufferUtils.createFloatBuffer(6)
            .put(new float[]{0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f}).flip();
    alListener(AL_ORIENTATION, orientation);
    FloatBuffer velocity = (FloatBuffer) BufferUtils.createFloatBuffer(3).put(new float[]{0.0f, 0.0f, 0.0f}).flip();
    alListener(AL_VELOCITY, velocity);
    FloatBuffer position = (FloatBuffer) BufferUtils.createFloatBuffer(3).put(new float[]{0.0f, 0.0f, 0.0f}).flip();
    alListener(AL_POSITION, position);

    recentSounds = new OpenALSound[simultaneousSources];
}